Naming Cells [Closed]

Report
-
 saints77 -
Hello,
TIA:
I have 16000 data pairs in each delimited text file.. Which l have quite a lot of.. and l have the wriitten the code for opening the files into an excel sheet, and have saving the file using its text file name. I want to be abe to include the naming of 16 cells that are correction factors for the data, the correction factors commence at B3 for five cells horizontally, then B4 for five cells, and so unitl all sixteen channels are listed, and once named l want to set up a table with the sixteen channels:
l have tried recording a macro, but that only works with the initial file, and l do not how to designate the macro for each new text file opened..
here's some of the code.. not complete and by no means correct... l have named each new file as vfilename, and this is a sub procedure that is called from my main program..

Sub TableSetup()


Dim Name1 As Range

Set Name1 = Worksheets("vFilename").Range("B3").Names.Add

MsgBox Worksheets('vFilename').Range('Name1').Value



ActiveWorkbook("file1").Range("B3").Select
ActiveWorkbook.Names.Add Name:="corr1", RefersToR1C1:="=file1!R3C2"
Range("C3").Select
ActiveWorkbook.Names.Add Name:="corr2", RefersToR1C1:="=file1!R3C3"
Range("D3").Select
ActiveWorkbook.Names.Add Name:="corr3", RefersToR1C1:="=file1!R3C4"
Range("E3").Select
ActiveWorkbook.Names.Add Name:="corr4", RefersToR1C1:="=file1!R3C5"
Range("F3").Select
ActiveWorkbook.Names.Add Name:="corr5", RefersToR1C1:="=file1!R3C6"

2 replies

Maybe you can try using the Name Property instead of using the R1C1 style reference.


Range("B3").Name = "corr1"
Range("C3").Name = "corr2"
Range("D3").Name = "corr3"
Range("E3").Name = "corr4"
Range("F3").Name = "corr5"
Thxks WutUp WutUp

worked like a dream... the reworking of VB has left me a little mysitfied, but am starting to decipher it... u were able to use the name property as the worksheet was the only active one..thxks again..

saints77

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!