Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It gives error at the
"Set sht = Sheets("sheet1").Range("A1").Value" line but I couldn't manage. thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Oercim,
Try this adaptation: '============= Sub d() Dim sht As Worksheet Set sht = Worksheets.Add sht.Name = Sheets("sheet1").Range("A1").Value Sheets("sheet2").Rows("10:20").Copy Destination:=sht.Range("A10") End Sub '<<============= --- Regards, Norman "oercim" wrote in message ups.com... 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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Norman, It gives error in line
"sht.Name = Sheets("sheet1").Range("A1").Value" Thanks alot. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello Norman, It gives error in line
"sht.Name = Sheets("sheet1").Range("A1").Value" Thanks alot. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What error is it giving?
Is Sheet1 the name of the reference sheet? Is the value in A1 a valid name? Do you already have a sheet with the name in A1? In article . com, "oercim" wrote: Hello Norman, It gives error in line "sht.Name = Sheets("sheet1").Range("A1").Value" |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, it worked. Thank u very much. Cheers
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Add sheet name into a variable. | Excel Worksheet Functions | |||
How To make a sheet reference Variable (eq: sum(sheet!D2:H2)) | Excel Discussion (Misc queries) | |||
Variable sheet and Formula Sheet | Excel Discussion (Misc queries) | |||
Sheet Name as a Variable? | Excel Programming | |||
variable in a link where the variable is the name of the sheet | Excel Worksheet Functions |