View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default The differents of the sheets name and caption.

There are two "names" for the sheet.

There's the name that you and the user see in the worksheet tab.

And there's a codename that you as a developer can see in the properties window
inside the VBE when you have that worksheet selected in the project explorer.

Hit alt-f11 to get to the VBE
hit ctrl-r to see the project explorer (much like windows explorer)
Select your worksheet in your project
hit F4 to see the properties window

You'll see a (name) property at the top. This is the Codename for that sheet.
You'll also see a Name (without the parens) -- that's the name on the worksheet
tab.

You can use the codename in your code to avoid problems with the user changing
the worksheet name on the tab.

But it looks like you did when you used sheet2.range("C2") in your sample code.

If you were using the Name (on the tab), your code would have looked like:

worksheets("sheet2").range("C2")





Axel wrote:

How do i paste the cellvalue in sheet2 range("C2") from
sheet("Ark1)range ("I14").
The user of the workbook has given sheet2 a new name when this macro i
running. So I has to use the "Real" name of the sheet.
The normal copy and paste only work with the "caption" of the sheet.
the ("Ark1")sheet is beeing deleted after, so I can't use a hyperlink.
The problem is at line 08-09.
Does sombody have a suggestion to my challenge please!

01. Private Sub CommandButton3_Click()
02. Dim c As range
03. Set c = ActiveCell
04. range("I14").Select
05. If IsEmpty(c) Then GoTo line2 Else GoTo line1
06. line1:
07. Sheet2.Visible = True
08. Sheet2.range("C2") = Worksheets("Ark1").range _
09. ("I14").Value
10. Sheet2.Name = Worksheets("Ark1").range("N14").Value
11. Line2:
12.
13. 'same thing here
14. End sub

Mvh Aksel

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson