Variable not defined?

D

davegb

I just started writing some new code, went to test the first few
lines, but I'm getting a "variable not defined" error on the name of
my subroutine. Anybody know what's wrong with the name?

Sub WklySumWS() <------- VARIABLE NOT DEFINED

Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String


Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name

Sheets.Add.Activate
wsWklySum = ActiveSheet
ActiveSheet.Name = sWklyShtName & " Summary"
End Sub

Thanks for the help!
 
D

Don Guillett

Option Explicit

Sub WklySumWS()
Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String


Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name
'=========
Sheets.Add
ActiveSheet.Name = sWklyShtName & " Summary"
]=============
End Sub
 
D

davegb

Option Explicit

Sub WklySumWS()
Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String

Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name
'=========
Sheets.Add
ActiveSheet.Name = sWklyShtName & " Summary"
]=============
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software



I just started writing some new code, went to test the first few
lines, but I'm getting a "variable not defined" error on the name of
my subroutine. Anybody know what's wrong with the name?
Sub WklySumWS() <------- VARIABLE NOT DEFINED
Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String
Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name
Sheets.Add.Activate
wsWklySum = ActiveSheet
ActiveSheet.Name = sWklyShtName & " Summary"
End Sub
Thanks for the help!- Hide quoted text -

- Show quoted text
Thanks for the reply, Don. It seems strange, after I posted, I want
back and ran the macro again, from the app rather then from the VBE,
and it ran. Don't understand that, but at least next time I get that
message I'll know to try running it from the app.
 
D

Don Guillett

I just tested your code and it did not run.???

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Option Explicit

Sub WklySumWS()
Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String

Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name
'=========
Sheets.Add
ActiveSheet.Name = sWklyShtName & " Summary"
]=============
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software



I just started writing some new code, went to test the first few
lines, but I'm getting a "variable not defined" error on the name of
my subroutine. Anybody know what's wrong with the name?
Sub WklySumWS() <------- VARIABLE NOT DEFINED
Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String
Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name
Sheets.Add.Activate
wsWklySum = ActiveSheet
ActiveSheet.Name = sWklyShtName & " Summary"
End Sub
Thanks for the help!- Hide quoted text -

- Show quoted text
Thanks for the reply, Don. It seems strange, after I posted, I want
back and ran the macro again, from the app rather then from the VBE,
and it ran. Don't understand that, but at least next time I get that
message I'll know to try running it from the app.
 
D

davegb

I just tested your code and it did not run.???

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

Option Explicit
Sub WklySumWS()
Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String
Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name
'=========
Sheets.Add
ActiveSheet.Name = sWklyShtName & " Summary"
]=============
End Sub
- Show quoted text

Thanks for the reply, Don. It seems strange, after I posted, I want
back and ran the macro again, from the app rather then from the VBE,
and it ran. Don't understand that, but at least next time I get that
message I'll know to try running it from the app.- Hide quoted text -

- Show quoted text -

I misspoke in my previous post. Originally, it would run because I was
getting the "Variable not defined" message, which went away when I ran
it from the app. There were other errors in the untested code that
came up when I attempted to run it, but the "Variable not defined"
message was gone, so I withdrew my original post, but you had already
answered. Got it running now. Thanks for the help.
 
D

Don Guillett

The archives would like to see your final code

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
I just tested your code and it did not run.???

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

Option Explicit
Sub WklySumWS()
Dim wbWkly As Workbook
Dim wsWklyLst As Worksheet
Dim wsWklySum As Worksheet
Dim sWklyShtName As String
Set wsWklyLst = ActiveSheet
sWklyShtName = wsWklyLst.Name
'=========
Sheets.Add
ActiveSheet.Name = sWklyShtName & " Summary"
]=============
End Sub
- Show quoted text

Thanks for the reply, Don. It seems strange, after I posted, I want
back and ran the macro again, from the app rather then from the VBE,
and it ran. Don't understand that, but at least next time I get that
message I'll know to try running it from the app.- Hide quoted text -

- Show quoted text -

I misspoke in my previous post. Originally, it would run because I was
getting the "Variable not defined" message, which went away when I ran
it from the app. There were other errors in the untested code that
came up when I attempted to run it, but the "Variable not defined"
message was gone, so I withdrew my original post, but you had already
answered. Got it running now. Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top