473,408 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Select case with public variables

I am trying to write a code that will look at the values in several worksheets and if the cell it looks at has the same value as the job number input by the user, I want to copy and paste the row into a worksheet called "Tracking Macro". I had the program running but the screen flashes as it runs so I decided to try altering it and use the screen updating = false line. However that meant I had to take out all the selection and active lines I used. Now the sub lookup will not run. Here is the start of the code...

Expand|Select|Wrap|Line Numbers
  1. Public StLook As Range
  2. Public LookSheet As String
  3. Public JobNum As String
  4. Public PrtCell As Range
  5. Public EndPrt As String
  6.  
  7. Sub output()
  8.  
  9. Dim ThisYr As String
  10.  
  11. On Error GoTo ErrHandler
  12.  
  13. Worksheets("Tracking Macro").Cells.Clear
  14.  
  15. Application.ScreenUpdating = False
  16.  
  17.     ThisYr = Worksheets("BNG Trends").Range("B1").Value
  18.     JobNum = InputBox("Please provide the BNG job number you wish to view:", "Job Number")
  19.  
  20.      Worksheets("Tracking Macro").Range("A4", "M4").Value = Worksheets(ThisYr & " Invoice Log").Range("A6", "M6").Value
  21.  
  22.         Set PrtCell = Worksheets("Tracking Macro").Range("A4")
  23.         EndPrt = "M"
  24.         Call format
  25.         LookSheet = ThisYr & " Invoice Log"
  26.         Set StLook = Worksheets(ThisYr & " Invoice Log").Range("A7")
  27.         Call lookup
That all runs ok, then I call the "lookup" sub and I get error message 438: "Object does not support this property or method." After some process of ellimination I believe it is that the computer is not recignizing "StLook" as a range. Help! I am fairly new to VBA programming. Here is the "lookup" sub...

Expand|Select|Wrap|Line Numbers
  1. Sub lookup()
  2.  
  3. Do While Worksheets(LookSheet).StLook.Value <> ""
  4.  
  5.     Select Case Worksheets(LookSheet).Range(StLook).Value
  6.     Case JobNum
  7.             Do Until PrtCell.Value = ""
  8.                 Set PrtCell = PrtCell.Offset(1, 0)
  9.             Loop
  10.  
  11.         Worksheets("Tracking Macro").Range("A" & PrtCell.Row, EndPrt & PrtCell.Row).Value = Worksheets(LookSheet).Range("A" & StLook.Row, EndPrt & StLook.Row).Value
  12.         Call format2
  13.  
  14.         Set StLook = StLook.Offset(1, 0)
  15.     Case Else
  16.         Set StLook = StLook.Offset(1, 0)
  17.     End Select
  18.  
  19. Loop
  20.  
  21. End Sub
Oct 27 '11 #1
0 1373

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
3
by: Parintas Themis STE Kardias | last post by:
Hi How can i use public variables. These variables i wand to use in different places on a form (like a button) and are neccessery to write the type of variable like: Public VAR1, var2 as integer...
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
3
by: pgraeve | last post by:
I am a convert from VB to C# so bear with me on this "conversion" question C# switch statement seems to be the closest relative to VB's Select Case. I used VB's Select Case statement liberally. ...
6
by: darrel | last post by:
I'm still not quite sure how best to handle the passing of data between controls. This is a method I'm using at the moment: I have an XML file that contains a variety of page-centric...
3
by: Paul Bromley | last post by:
I have just started to use Classes a lot in my code. Often I find that I need to use the same contstructor, but wish to invoke a different action depending on where I am clling the class from. I...
2
by: James | last post by:
i wrote a filewatcher application and inside the code, i've a select case statement : Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)...
16
by: ME | last post by:
In C# the following code generates a compiler error ("A constant value is expected"): public void Test(string value) { switch (value) { case SimpleEnum.One.ToString(): MessageBox.Show("Test...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
43
by: Mac rod | last post by:
Hi everyone, could you please help me. i have a combo box that have the values "1st month", "2nd month" etc, a text box to put details such as weight, length and ccirc. what i want to do is when a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.