View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Gisela Gisela is offline
external usenet poster
 
Posts: 13
Default variable sheet name

Is there a way to refer to use a variable as the sheet name in a macro? I
getting run time error 424 he

Set wsFrom = Sheets("Menu").Cells(w, 19).Value

For example, let's say that in columns S, I've got the names of sheets that
I want to refer to...

Column S
Sheet7
Sheet8
Sheet9
Sheet10

Dim wsFrom As Worksheet

I want to move the cell value to:

Set wsFrom = Sheets("Menu").Cells(w, 19).Value

whe w = 1 <---row 1 of column S; it increases by one until the product
changes

The purpose is to move certain data to a different worksheets (some code is
included)
Do Until IsEmpty(Sheets(wsFrom).Cells(x, 2))
'This will move the value of each column within each row to Data
worksheet
Do Until y = 19
Sheets("Data").Cells(x, y).Value = Sheets(wsFrom).Cells(x, y).Value
'increase the value of y by 1 to act on the next column
y = y + 1
Loop
'increase the value of x by 1 to act on the next row on Data worksheet
x = x + 1
'sets the value of y to 2 to act on the first column to move next row data
y = 2
Loop