LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Subroutine question and public variables


I am rather new to excel programming and I am
trying to figure out some basic things. First, I am not sure how to
declare and set a public variable. For example, in my code, I have 2
constants that represent spreadsheets. The code looks like this:


Code:
--------------------
Public sh As Worksheet
Public ls As Worksheet
Set sh = Worksheets("Assemblies")
Set ls = Worksheets("Assemblylist")
--------------------


I am not sure as to why this doesn't work.

Secondly I am trying to create a subroutine that looks for a column,
row, or both that meet certain criteria. This could be a column that
matches another field in my userform or has nothing in it. I wrote the
following code that should work, but I don't know where to put it or how
to call it once it is put there.


Code:
--------------------
Sub lookup()
Dim direction As Integer '1 for columns 2 for rows 3 for both
Dim y As Integer 'row integer
Dim x As Integer 'column integer
Dim z As String 'Don't really know what to declare this as, could be a word or a number


Do While sh.cells(y, x) < z
If direction = 1 Then x = x + 1
If direction = 2 Then y = y + 1
If direction = 3 Then x = x + 1
If direction = 3 Then y = y + 1
Loop
--------------------


Any help would be greatly appreciated.


--
musictech
------------------------------------------------------------------------
musictech's Profile: http://www.excelforum.com/member.php...o&userid=24851
View this thread: http://www.excelforum.com/showthread...hreadid=383979

 
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
public variables johnny Excel Discussion (Misc queries) 7 February 27th 08 03:44 PM
Public variables johnny Excel Discussion (Misc queries) 2 February 24th 08 05:05 AM
Public Variables ExcelMonkey[_190_] Excel Programming 5 February 21st 05 10:12 AM
Public Variables Les Gordon Excel Programming 2 November 11th 04 12:29 PM
Public subroutine called from a private sub Neil Bhandar[_2_] Excel Programming 1 January 15th 04 10:23 PM


All times are GMT +1. The time now is 06:21 AM.

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

About Us

"It's about Microsoft Excel"