Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've created a macro that loops through a range of single values in a
column. I'm trying to figure out whether its possible to have 4 columns in each row of values and obtain the first, second and third value and put the value of each in a specific cell. The macro filters a bunch of data in a template and then creates a new document from an .xlt file and copies the data into it, saves and closes the file. An Extract of the macro is: Sub CreateReports() For Each c In Range("loop.range") Windows("2008-09 Budget Template - master.xls").Activate Worksheets("BA Report").Activate Worksheets("BA Report").Range("BCostCentre") = c.Value This is ok as BCostCentre is 1 cell.... What I want to do is extend loop.range to 4 columns of unique values that I want to report on and not sure how to code it. I was thinking it would be something like.... Sub CreateReports() Dim fname As Variant Dim bname As Variant For Each c In Range("loop.range") Windows("2008-09 Budget Template - master.xls").Activate Worksheets("BA Report").Activate Worksheets("BA Report").Range("BCostCentre1") = c.Value(1) Worksheets("BA Report").Range("BCostCentre2") = c.Value(2) Worksheets("BA Report").Range("BCostCentre3") = c.Value(3) Worksheets("BA Report").Range("BCostCentre4") = c.Value(4) ....... then save the new file.... bname = "(" & Worksheets("BA Report").Range ("BCostCentreDescription").Value & ")" fname = c.Value & " - " & bname & " - 08.09 BUDGET TEMPLATE" & ".xls" ..... currently, the name of the file for this would be.... 2340100 - Collection & Content Devel Div - 08.09 BUDGET TEMPLATE.xls What I'm hoping to do is to modify it too something like fname = c.Value(1) &"-"& c.Value(2) &"-"& c.Value(3) &"-"& c.Value(4) & " - " & bname & ....... is this the correct syntax or am I way out? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Referring to first cell in a range | Excel Discussion (Misc queries) | |||
Referring first row in range | Excel Programming | |||
Referring to a named range | Excel Programming | |||
Referring to cells in a filtered range | Excel Programming | |||
referring to a range | Excel Programming |