View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default How do I change a variable name based on a sheet name

Hi,

Maybe this

Sub nn()
myvar = "strSales"
For x = 1 To Worksheets.Count
myvar = myvar & x

'your code


myvar = "strSales"
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"The Avenger" wrote:

For example, lets say I have a string variable named strSales, I want to
iterate through the sheets, so when I'm on sheet 1, it'll be strSales1, on
sheet 2 it'll be strSales2, etc.