Name File Based On First 2 Characters In A Cell

Aug 11, 2006

I'm trying to find a way to save a file based on the contents of cell A2. I've modified the code to Create Worksheets for Each Item in an Excel Table of Data, so that it creates a new workbook for each item. I am also trying to get it to save the master workbook based on the first 2 characters in the cell. Here is the code I have, at the moment (the FAIL.xls is what I put in for testing)

If Range("A2").Value = "YE*" Then
ActiveWorkbook.SaveAs "YE_Master.xls"
ElseIf Range("A2").Value = "NE*" Then
ActiveWorkbook.SaveAs "NE_Master.xls"
Else: ActiveWorkbook.SaveAs "FAIL.xls"
End If

I've tried this, string arrays and everything else I can think of, and it's failing every time.

View 3 Replies


ADVERTISEMENT

Delete Characters Unallowed In File Names In Cell Text

Feb 14, 2012

How can I delete characters unallowed in file names in cell text all in one go instead of below long macro. (i.e. can you minimize the below vba)

These characters that I wanna delete
"/", "", ":", "*", "?", "< ", ">", "|"

Code:
Range("A1").Select
Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _

[Code].....

View 6 Replies View Related

Delete Row Based On First 4 Characters Of Cell

May 4, 2006

I need a way to check to see if the first four characters of cell A1 is = 2006. If it is, do not delete the row, else, delete the row. Have tried everything I can think of.

View 5 Replies View Related

Launching Macro Based On Selected Cell Value (first Two Characters?)

Sep 6, 2013

I have a macro to sort a very large list of materials by a variety of conditions.

The macro runs automatically when a cell on the master list spread sheet is selected and using If/ElseIf it sorts based on what cell they have selected.

Example
If ActiveCell = "ALUMINIZED" Then
ActiveSheet.Range("$A$14:$K$1945").AutoFilter Field:=2
ActiveSheet.Range("$A$14:$K$1945").AutoFilter Field:=4
ActiveSheet.Range("$A$14:$K$1945").AutoFilter Field:=1, Criteria1:= _"Aluminized"

Which is working perfectly. The problem I am having is that some of the cells are two lines so it looks like this:

BE
BEARINGS

I don't know how to get it to launch based on that cell content because of the line break in there. Can I make it launch based on the first two characters only?

View 5 Replies View Related

Restrict Cells Text To X Characters Based On Corresponding Cell

Apr 14, 2009

I'm am trying to restrict the length of data that can be entered into a cell based on a drop down in that row. I have achieved this, but what I need to be able to do is use data validation to restrict the cell length to one of two values - so for example the length can only be 6 OR 9 characters long.

I cant see how to do this. At present the best I can do is rectrict to between 6 and 9 - but this would allow 7 and 8 which is not allowed.

View 3 Replies View Related

External File(s) Referenced And File Links Change Based On Row Cell

Oct 22, 2009

I have attached the file I am working on. I am attempting to create a link to an external file based on the value of cells in column A. Then I would like to simply copy the formula down, lets say in Column B, the rows and as I do the external file reference will change depending on the value within the cell in Column A. I hope that I am making sense.

I am using Windows Vista with Excel 2007. The files will all be within the same file folder, however, there are hundereds of files so I won't be able to open them all for the indirect to work.

View 9 Replies View Related

Save Each Worksheet As PDF File And Name Each File Based On Cell Value In Each Sheet

Jul 10, 2014

I have a Workbook that already has a macro in it that will generate multiple sheets based on certain criteria.

For each of these newly generated sheets (numbered 1-6 in the attached example), I need to be able save each of them to a PDF file based on a unique name contained in a certain cell (in this case, each named is referenced in cell Q1 of each sheet). As such, I should end up with 6 pdfs based on the attached sample files.

The PDFs would ideally need to be landscaped and should be just 1 page per sheet.

In my attached sample workbook, you'll notice that I have a "PracticePrint" macro that doesn't quite get the job done. One other criteria involves not printing any sheet with the characters "1010" in it (my PracticePrint macro is setup to do that, but it fails to do much else).

View 1 Replies View Related

Get The Name Of The File In A Vlookup VBA Using Wildcard Characters?

May 17, 2014

get the name of the File in a Vlookup VBA using wildcard characters. I have to do a VLOOKUP from a specific file which is stored in the same folder as the file in which I need to get this VLOOKUP done, however the name can change anytime keep a word common only for this specific file...

Ex:
I have a File called "Mapping as on 8th May" from where i need to lookup some information for my file and I intend to do this using VLOOKUP in VBA in a Module but since the name can change to anything such as"Mapping as on 16th May" I cant use it in the VBA code, so is there a way around this where If I have this file stored in the same folder then I keep the word "Mapping" specific and unique for all other files in the same folder that the search can pull this file name to be further used in my lookup..

how to use the wildcards in VLOOKUP lookup range for the file name as the columns are going to remain the same...

View 13 Replies View Related

Can I Open A File By Searching For First Six Characters?

Nov 26, 2008

I have a number of project files that are maintained on the network.

These files are named "XXXXXX Project Name.XLS".

XXXXXX is the project number. This numbers are unique, so there is only one file per number within the directory. Project names are mostly unique, but sometimes they could be same for a specific site.

We recieve financial data in excel file format from home office. These reports reference only the project numbers, not the name.

I have created an excel program that extracts project numbers and related financial data from the report [from home office].

I would like to create a button or check box next to each project number in my program and link it to the respective file on our network. Once I access the local file on the network I could copy the financial data in its right place.

The problem is opening the file based on project number only, while the file names contain Project Name as well.

So, can I look up a file by only searching for first six characters of the name?

Or can the Hyperlink function work with some sort of wildcard? I can write the formulas to create the hyperlink and then write a macro to look for that file, but I need to be able to find and open the file by looking up only the first six characters.

View 9 Replies View Related

Deleting Characters From A Word File

Nov 10, 2006

I'm trying to automate a redundant task. I have several Word files in one central folder. I need to open each file, remove all paragraph marks (via find/replace all), copy the result, and paste it into an Excel sheet. This process will be repeated for each file in the folder.

The code I have is almost there, however, I can't get it to do the find/replace. Below is an extract of my code for the Word application part. The code for the copy and paste will be inserted after the replace action works:

Dim Wapp As Object
Dim i As Integer

WorksheetsLocation = TextBox1.Value ' this is the folder location brought in from an input box

On Error Resume Next
Set wApp = GetObject(, "Word.Application")
If Err.Number 0 Then 'Word isn't already running
Set wApp = CreateObject("Word.Application")
End If
On Error GoTo 0

View 9 Replies View Related

Remove Illegal Characters From File Name

Dec 7, 2006

Remove Illegal Characters From File Name ...

View 5 Replies View Related

Read In Multibyte Text File Characters

May 28, 2008

I have a Text-File with characters coded in simple chinese (gb2312) rsp. codepage 20936 and I want to read this file, paste the content in my worksheet. Later (after a chinese edited the text) I've to write this back to a text file.

The only way I found to make this, is by copy/paste e.g. from WordPad, but I want to automate it with VBA.

View 6 Replies View Related

Excel 2010 :: Save CSV File With Non-English Characters?

Dec 5, 2012

I run excel 2010... I have xls file (see file attached) with both English and Non English characters.

When I save this file as xls or xlsx - everything is good, but when I save the file as CSV and try to open it later - I see that the English characters stays the same but the non English characters become gibberish.

How can I save a file (that include some non English characters) as CSV without loosing the non English characters? Is there a way to do that from within the excel 2010 menus? Or maybe there is an external tool?

Attached file : 913365454523.xls‎

View 1 Replies View Related

Change Characters In Specific Position Of A Text File

Aug 6, 2008

I have a very large file of data, over 500,000 rows, opening in one sheet in Excel is not an option with my current version. In each row I need to change the characters in positions 41-44 from whatever they current are, to '9999'. I'm sure there has to be a way I can do this using vba, does anyone have a sample snippet of code, or another post they can point me too?

View 9 Replies View Related

Hyperlink To File Based On Cell Value?

Sep 29, 2012

Basically I have a folder with file names in the format:
"XXXXX characterstring"
where X is a digit

E.g.:
45627 -jdsuuuds.pdf
93823 Coates.pdf
98221 dagggiisa d sass.pdf

And I have an excel sheet with a list of the numbers at the start of these file names, eg:
45627
93823
98221

So what I want to do is have each cell link to the file with the corresponding number. So I click "45627" and it links to "C:path45627 -jdsuuuds.pdf"

I could do it if the file names matched exactly to the cell value, but when they don't.

It's super easy when the file name matches exactly:

VB: ActiveCell.Hyperlinks.Add ActiveCell, "C:path" & ActiveCell & ".pdf"

VB:
Sub makelinks() ChDrive "c"
ChDir "c:pathl"

For Each ce In Selection
filee = Dir(ce.Value & "*.pdf")

[Code]....

View 2 Replies View Related

Open File Based On Cell Value

Aug 27, 2007

I am using the following code to open an existing file whose name is in cell A1. I want to modify the code so that if the spreadsheet does not exist, a template (Costing.xlt), in the same director, is opened and then saved with the name in cell A1.

Workbooks.Open Filename:="C:Spreadsheets" & Range("A1") & ".xls"

View 3 Replies View Related

Lookup File Based On Cell Value

Jan 24, 2008

In my sheet I do a vlookup for the value in column A in another worksheet. What I would like to do is depending on a value in column C the vlookup would look in a different worksheet. So if the value of "C1" were "AP" the vlookup would go to, for example, table1.xls/sheet1. Say down the line I wanted to change the value of "C1" or the value of column C in another row was "GNR" the vlookup formula would look to table2.xls/sheet1.

View 4 Replies View Related

Save File As Pdf Based On Cell Reference A4?

Mar 6, 2014

I want to save my file as a pdf based on cell reference A4.

This is what i have

[Code] ....

View 2 Replies View Related

Open File Based On Cell Data

Aug 11, 2008

is there a way using VBA code that you can have a file path entered into cell 'A1'

and then when you run the macro, the file referenced in the file path in cell 'A1' will open,

View 14 Replies View Related

Open A File Based On Cell Text?

Oct 6, 2011

I want to create a Macro to open a file based on the data of a particular cell to update the data for macro file from that file.

For example I have 3files named Dept1, Dept2, Dept3 and I have one more file named Cost Sheet which contained macro and based on the cell D2 of my macro file I need to open the particular file i.e Dept1, Dept2 or Dept3 and the updated procedure and cell ranges are same for all file

View 2 Replies View Related

Open File With Name And Folder Based On Cell

Nov 20, 2007

I would like to run a macro that is going to open a file (Test.xls) Simple so far....
However, this file is 1. stored every month in a different folder (eg: 200709,200710, etc..) and the file is named according to the month (eg: Test09.xls, Test10.xls, etc...)
In my excel book, I did created two cells which I already use to save a document according to those cells. One cell with Acct Period (200710) and another one with the month (10).
I have tried the following formula with no success:

OpenWorkbook "\pathpathpath" & Range("Accout Period") & "Test" & Range("Month") & ".xls"

View 9 Replies View Related

Link Formula To File Based On Cell Value

Jan 22, 2008

I have a problem that may be a little bit diff. from must of the Readonly post that I have found here. Most people would like to have all of there files opened as readonly files, but I don't in this case. I am copying a number of files that has VBA code in just about all of them. I am using a CD writer to copy the files to a CD using Windows Explorer and that is working just great, No problem copying the files.

My problems comes in when I copy the files from the CD to another computer, all of the files are Readonly files on the new PC. I have not saved them as readonly and don't want them to be readonly files. Does anyone have any ideas why this is happening what I need to check or change to get the files to another computer without being a readonly file.

View 2 Replies View Related

Email File. Recipient Number Based On Cell Value

Jun 26, 2007

it is possible to set up a macro that can route a file to specific people based on conditions in the file? what i am trying to do is route via email a excell file on dollar amount. So if file is for $10,000 ; send it to 2 specific people. If its for $90,000 send to specific 4 people.

View 4 Replies View Related

Excel 2013 :: Playing WAV File Based On Cell Value Change

Aug 6, 2014

I have a spreadsheet with a database query attached (refreshing every 60 seconds) showing a stock summary by product.

I need the spreadsheet to play a .WAV file when values change. i.e.;

If cell A1 <6, play sound1.wav
If cell A2 <6, play sound1.wav
If cell A3 <6, play sound2.wav
If cell A4 <6, play sound2.wav

This may need to be repeated several times based on certain criteria. I have a total of about 30 cells which I need to be looked at individually (not a sum of) and to play the relevant sound.

I have seen different people try to tackle this in different ways. The ideal way would be creating alarms in VBA and triggering them using a formula, but I cannot get these to work in Excel 2010 or 2013.

View 6 Replies View Related

Take X Characters From One Cell And Y Characters From The Next?

Aug 1, 2014

So we have people's names in a table. First name in one column and last name in another column. We have a 3rd column where we can use 8 characters to do a combination of First 5 of Last Name + first 3 of first name. However, if someone's last name is only 3 or 4 characters, we'd then want to take more from the first name to fill out the 8 characters.

So:
Charles Johnson -> Johnscha
John Smith -> Smithjoh
Willian Wu -> Wuwillia

What's the best way to do that without creating some crazy formula with tons of if/thens?

View 4 Replies View Related

Excel 2010 :: Building Text File Based On Values Of Cell?

Feb 26, 2014

I'm trying to use Excel to build a text file based on values from certain cells in Excel 2010. This is based partially off of static text that never changes and variables that will need to change. For example, I want Excel to output a text file that has the following text: The red fox jumped over the $X twice. I would want $X to be replaced by the value of A1 of the active worksheet. I will also have several lines like that, so it won't just be a single line, but anywhere from 20 - 120.

View 1 Replies View Related

Macro To Save Duplicate File And Create Folder Name Based On Cell Value

Nov 25, 2009

I currently use the following code to create a duplicate file based on two cells within a directory and folder i specify. These cells consist of the team and week commencing date (mondays date of week which is cell 'Main Menu'!K8)

View 7 Replies View Related

Sum A Column Based On Alpha Characters

Mar 6, 2007

I have columns and rows that are populated with one of three letters: P, S, & T. At the bottom of the column and at the end of the row, i'd like to assign a numeric score to the entire column/row that is based on converting the characters to a numeric eqivelant. P = 3, S = 2 and T = 1. I'm guess a case statement would be used, but not too sure here. So, I'd need the code behind the worksheet as well as the formula(s) used for the score. I've attached an example.

View 3 Replies View Related

Excel 2007 :: Saving File With Name Based On Cell Contents With Custom Formatting

Aug 16, 2012

I have a worksheet that has a number in cell K5 - the number is generated on "file open" code and is custom formatted as "TN"0000. Thus 1 appears as TN0001, 2 as TN0002 and so on. I am trying to save a copy of the workbook based on the this cells contents i.e. TN0001.xls, TN0002.xls etc. but the files are saved as 1.xls or 2.xls. The code I am using is

ActiveWorkbook.SaveAs Filename:="C:DataExcelFORMSDelivery Note" & Range("K5") & ".xls", _
FileFormat:=xlNormal, ReadOnlyRecommended:=True, CreateBackup:=False

I know I must make reference to format within the above....but how? if try something like

" & Format(Range("K5").Value, ("TN""0000")) & ".xls"

I get TN00000.xls

View 2 Replies View Related

Extract Numeric Value Based Upon Ending Characters

Jan 10, 2014

I have a list of numbers in which I need to return the last 5 digits; the length of the string may vary.

However, if the last two digits of the number ends in a specific value then it should skip over the last two numbers and return the preceding 5 digits.

I have tried and have used the very basic Left, Right and Mid functions. My problem is I dont know how to code the formula to identify the last two digits and skip over them, if necessary.

I have provided an attached example.

Extract numeric value based upon ending characters.xlsm

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved