Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Storing variable values in Excel worksheet

Hello,

I have created a Userform that will automate the
building of 55 Excel workbooks. Instead of
hardcoding the variables in a VBA module,
I would like to store the values in an underlying
worksheet, (A1:C55) and loop through the values.

How would I do this?

The spreadsheet data would look like this...

A B C
1 North Area_01 IC_Regn_01
2 North Area_01 PI_Regn_01
3 South Area_02 IC_Regn_04

.... and would be called using something like

Dim x as Territory
Dim y as Area
Dim z as Region

Do Until ???

' Do something with x
' Do something with y
' Do something with z

Loop

Any help you can lend would be appreciated.

Henry

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default Storing variable values in Excel worksheet

Hi Henry

You would need something like

Dim i as long, x as long
Dim y as String, z as string

For i = 1 to 55
x = Range("A" & i).Value : y = Range("B" & i).Value : z = Range("C" &
i).Value

do your stuff with these
Next i


--
Regards

Roger Govier


"Henry Stockbridge" wrote in message
oups.com...
Hello,

I have created a Userform that will automate the
building of 55 Excel workbooks. Instead of
hardcoding the variables in a VBA module,
I would like to store the values in an underlying
worksheet, (A1:C55) and loop through the values.

How would I do this?

The spreadsheet data would look like this...

A B C
1 North Area_01 IC_Regn_01
2 North Area_01 PI_Regn_01
3 South Area_02 IC_Regn_04

... and would be called using something like

Dim x as Territory
Dim y as Area
Dim z as Region

Do Until ???

' Do something with x
' Do something with y
' Do something with z

Loop

Any help you can lend would be appreciated.

Henry



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Storing variable values in Excel worksheet


here is 2 examples of getting the data from an existing sheet into a
macro

the 1st one loads a1 to c55 into a variable array
the 2nd one displays a message box with the cells value

Sub ArrayMacro()
Dim myArr(1 To 3, 1 To 55)
Dim iRow As Integer
Dim iCol As Integer
For iRow = 1 To 54 Step 1
For iCol = 1 To 3 Step 1
myArr(iRow, iCol) = Sheets("Sheet1").Cells(iRow, iCol)
Next iCol
Next iRow

End Sub



Sub MyCode()
Dim iRow As Integer
Dim iCol As Integer
For iRow = 1 To 54 Step 1
For iCol = 1 To 3 Step 1
'do something with using the next line of code
MsgBox Sheets("Sheet1").Cells(iRow, iCol).Value
Next iCol
Next iRow
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=535903

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Storing variable values in Excel worksheet

Thanks for the help. I'm all set now...

Reply
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
Storing a value to variable CLamar Excel Discussion (Misc queries) 0 June 16th 06 04:46 PM
excel storing previous cell values in memory Brent Bortnick Excel Worksheet Functions 2 April 19th 06 09:00 PM
Storing variable in Option.Tag augustus Excel Programming 0 February 4th 05 02:45 AM
Storing a Macro name in a Variable Jack Adams Excel Programming 2 October 5th 04 03:59 PM
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet Ant Waters Excel Programming 1 September 3rd 03 11:34 AM


All times are GMT +1. The time now is 03:09 AM.

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

About Us

"It's about Microsoft Excel"