troubleshoot ActiveSheet.Name
Upcoming Power Excel Seminars
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: troubleshoot ActiveSheet.Name

  1. #1
    Guest

    Default

     
    Hello, can anyone out there see a reason the following code would fail? I had the EXACT code in another macro that worked fine. I have gone through this macro line by line and all works well except the second (and probably 2nd to last) lines refering to shtOriginal. What happens is that when I run the macro it will debug with the 2nd line 'shtOriginal' phrase highlighted and the error message 'variable not defined'. The purpose of the second and 2nd to last line is so that after the info is copied and pasted to the '5th worksheet' I want it to then return to WHICHEVER of the worksheets (1-4) the user was last on.
    Sub HELP()
    '
    ' CutPaste Macro
    ' Macro recorded 26/02/2002 by
    '

    '
    Application.ScreenUpdating = False
    shtOriginal = ActiveSheet.Name
    ActiveCell.Rows("1:1").EntireRow.Select
    Selection.Copy
    Sheets("My Class").Select
    ActiveCell.Offset(1, 0).Range("A1").Select
    ActiveSheet.Paste
    With Selection.Font
    .Name = "Arial"
    .Size = 8
    End With
    Sheets(shtOriginal).Select
    ActiveCell.Offset(1, 1).Activate
    Application.ScreenUpdating = True
    End Sub

    Any ideas? Many thanks if so!

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Las Vegas Nevada USA
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try this at the top of your code

    Dim shtOriginal As String

  3. #3
    Guest

    Default

    That did the trick, Mr. Las Vegas!! Thanks a million from Australia

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Las Vegas Nevada USA
    Posts
    239
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Nice of you to offer up a thank you. Good on ya Mr Down Under

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com