View Full Version : Question on Variables


hardhat
10-03-2006, 07:07 AM
I have written a macro to process a number of files, import them and turn them into excel spreadsheets. I have acheived this using a loop and all works well. What I would like to do is name the sheet and the file using the customers name.

The loop value for example is:

top10 = 1

I have set the customers as such:

cust1 = bob
cust2 = john
cust3 = dave

I now need to call the customer name from within my loop but I'm not sure how to concatenate a tag with the contents of a variable:

Sheets(sheetname).Name = cust & top10

(this does not work but hopefully you can see what I am trying to acheive with the result being a variable cust1 giving a sheet name of bob)

I hope this makes sense.

Ziggy1
10-17-2006, 07:24 PM
this will name the sheet, just modify accordingly

Public Sub sheetname()

Dim cust As String
Dim top10 As Double

cust = "Steve"
top10 = 1

ActiveSheet.Name = cust & top10
End Sub