M
musictech
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
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