![]() |
|
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Try this at the top of your code
Dim shtOriginal As String |
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
That did the trick, Mr. Las Vegas!! Thanks a million from Australia
|
|
|
|
#4 |
|
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Nice of you to offer up a thank you. Good on ya Mr Down Under
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|