Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Variable Declaration??

the partnumber in checkpartnumber is local to the checkpartnumber routine
because it is in the argument list.

Therefore, the Public variable PN is never set.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
If Target.Column = 1 And Target.Row 1 Then _
Call CheckPartNumber(Target.Value)
End Sub

Option Explicit

Sub CheckPartNumber(PN)
MsgBox "PN is: " & PN
ChkLen PN
End Sub

Sub ChkLen(PN)
MsgBox "ChkLen PN is: " & PN
MsgBox "Len of PN is: " & Len(PN)
End Sub


Should work.

--
Regards,
Tom Ogilvy

"Otto Moehrbach" wrote in message
...
Excel 2002, Win XP
I am making a very basic mistake in the following macros and I can't

see
it.
The first macro simply calls the 2nd macro and passes Target.Value to
it.
The 2nd macro calls the third macro and that's when things go wrong.
Because I am using "PN" in more than one macro, I declared "PN" at the
top of the module. I think here is the mistake but I can't see it.
Target.Value is a 15 character string.
The MsgBox in CheckPartNumber shows that PN is the 15 Chr string.
The 2 MsgBox's in ChkLen show that PN is nothing with a length of 0.
Question: What happened to the value of PN? Thanks for your help.
Otto

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
If Target.Column = 1 And Target.Row 1 Then _
Call CheckPartNumber(Target.Value)
End Sub

Option Explicit
Dim PN As String
Sub CheckPartNumber(PN)
MsgBox "PN is: " & PN
ChkLen
End Sub

Sub ChkLen()
MsgBox "ChkLen PN is: " & PN
MsgBox "Len of PN is: " & Len(PN)
End Sub




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Variable Declaration??

Thanks Tom. My work-around was just what you said to do but you explained
it for me. Thanks again. Otto
"Tom Ogilvy" wrote in message
...
the partnumber in checkpartnumber is local to the checkpartnumber routine
because it is in the argument list.

Therefore, the Public variable PN is never set.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
If Target.Column = 1 And Target.Row 1 Then _
Call CheckPartNumber(Target.Value)
End Sub

Option Explicit

Sub CheckPartNumber(PN)
MsgBox "PN is: " & PN
ChkLen PN
End Sub

Sub ChkLen(PN)
MsgBox "ChkLen PN is: " & PN
MsgBox "Len of PN is: " & Len(PN)
End Sub


Should work.

--
Regards,
Tom Ogilvy

"Otto Moehrbach" wrote in message
...
Excel 2002, Win XP
I am making a very basic mistake in the following macros and I can't

see
it.
The first macro simply calls the 2nd macro and passes Target.Value

to
it.
The 2nd macro calls the third macro and that's when things go wrong.
Because I am using "PN" in more than one macro, I declared "PN" at

the
top of the module. I think here is the mistake but I can't see it.
Target.Value is a 15 character string.
The MsgBox in CheckPartNumber shows that PN is the 15 Chr string.
The 2 MsgBox's in ChkLen show that PN is nothing with a length of 0.
Question: What happened to the value of PN? Thanks for your help.
Otto

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target = "" Then Exit Sub
If Target.Column = 1 And Target.Row 1 Then _
Call CheckPartNumber(Target.Value)
End Sub

Option Explicit
Dim PN As String
Sub CheckPartNumber(PN)
MsgBox "PN is: " & PN
ChkLen
End Sub

Sub ChkLen()
MsgBox "ChkLen PN is: " & PN
MsgBox "Len of PN is: " & Len(PN)
End Sub






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Declaration. apis Excel Discussion (Misc queries) 1 November 5th 11 01:53 PM
Adding a variable into a range declaration Malvaro Excel Worksheet Functions 2 June 24th 08 06:28 PM
Workbook Declaration Varne Excel Discussion (Misc queries) 3 April 29th 08 09:49 AM
VBA - variable declaration Jeff Excel Discussion (Misc queries) 3 January 9th 08 12:45 PM
type declaration characters integreat Excel Discussion (Misc queries) 1 July 17th 06 10:02 PM


All times are GMT +1. The time now is 12:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"