I have a "test workbook" that I use when I'm trying to figure out how to make something work... then after I fiddle with the code enough to (finally) get it to work the way i need to, I copy it over to my main workbook.
Well, i have checked every conceivable thing that I thought it could be (property settings, names, workbook settings, etc) and it still wont work in my main one(?)
Here is the code:
This is the line that is snagging it up after I copy it over to the main workbook (if I temporarily take it out, it runs):
The code has no problem running in my 'test workbook':
Working just fine on my test workbook...
But i get this errror after copying and pasting into my other (main) workbook....
What do I have wrong that it wont run with that line of code?? THank you
Keith
Well, i have checked every conceivable thing that I thought it could be (property settings, names, workbook settings, etc) and it still wont work in my main one(?)
Here is the code:
Code:
Private Sub CommandButton1_Click()
Dim fCell As Range
Dim ws1 As Worksheet
Dim vMax As Variant
Set ws1 = Worksheets("Sheet1")
[COLOR=#008000]' sets a range for column "A" on worksheet1 starting at row 18 and going down to the last entry that is in that column[/COLOR]
For Each fCell In Worksheets("Sheet1").Range("A18", Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp))
[COLOR=#008000]'finds the cell with the highest value in the previously defined range of 'fCell'[/COLOR]
vMax = Application.WorksheetFunction.Max(Range(Cells(18, 1), Cells(fCell, 1)))
Next fCell
[COLOR=#008000]'posts the highest value cell in fCell range and places it in a text field on the userform[/COLOR]
Me.txtIncidentID.Value = vMax
End Sub
This is the line that is snagging it up after I copy it over to the main workbook (if I temporarily take it out, it runs):
Code:
vMax = Application.WorksheetFunction.Max(Range(Cells(18, 1), Cells(fCell, 1)))
The code has no problem running in my 'test workbook':
Working just fine on my test workbook...
But i get this errror after copying and pasting into my other (main) workbook....
What do I have wrong that it wont run with that line of code?? THank you
Keith