LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Referring to value in range

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referring to first cell in a range FARAZ QURESHI Excel Discussion (Misc queries) 5 December 26th 07 05:14 PM
Referring first row in range Asif Excel Programming 4 October 4th 07 02:26 AM
Referring to a named range Darin Kramer Excel Programming 2 March 1st 07 05:26 PM
Referring to cells in a filtered range Stefi Excel Programming 5 October 27th 05 10:48 AM
referring to a range Kevin Smith[_3_] Excel Programming 2 September 7th 04 12:24 PM


All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"