View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
oercim oercim is offline
external usenet poster
 
Posts: 51
Default sheet name as variable

Hello. In excel macro, I want to make below statements:

1. adding a sheet whose name is a variable( name is taken
from the the cell:sheet1,A1)
2. pasting some rows from another sheet to added sheet.
I made the below code, but it doesn't work

Sub d()
Dim sht As Worksheet

Set sht = Sheets("sheet1").Range("A1").Value

Sheets("sheet2").Rows("10:20").Copy.Sheets(sht).Ra nge("A10")
End Sub

Thanks a lot.