wolf.stalker
11-08-2009, 06:50 AM
ok, about ready to put a rock through my PC :banghead:
I have a worksheet. On this workshet (in column A) contains store numbers. now, I do a ctrl+f and type in a store number (while recording a macro) and it finds the first occurance of it. THIS IS GREAT AND ALL I FRIGGIN WANT!
now, i take that macro that just recorded and walk through it WITHOUT changing a thing and get a friggin Run-time error 1004.
all night it has been like this.
anyone have any ideas? oh here's the code.
What do i need to add so that it selects the cell of the first instance like the functions performs when run through Excel (not a macro?)
Public Sub FindData()
Dim iCount As Integer ' counts the # of times it shows up
Dim iSiteCount As Integer ' counts the number of stores on sheet
iSiteCount = Application.WorksheetFunction.CountA(Sheets(4).Range("B:B")) ' this part works fine and returns a value of 1702
iCount = Application.CountIf(Sheets("Tank Size Info").Range("A:A"), Sheets("Form").Range("A2")) ' this part works find and retruns a value of 3
Sheets("Tank Size Info").Select ' select my target sheet to look at
MsgBox Sheets("Form").Range("A2") ' to see if what i am looking for is on the sheet...as it happens to be 68809, i took the long code out and just used the number until i can figure out the issue. Pops up 68809
MsgBox Cells.Find(What:=Sheets("Form").Range("A2"), LookAt:=xlWhole)
'Sheets("Form").Range("A2") ' also pops up 68809
Cells.Find(What:="68809", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activate 'crashes everytime
End Sub
ok, what am i doing wrong here? what am i missing or forgetting?
I have a worksheet. On this workshet (in column A) contains store numbers. now, I do a ctrl+f and type in a store number (while recording a macro) and it finds the first occurance of it. THIS IS GREAT AND ALL I FRIGGIN WANT!
now, i take that macro that just recorded and walk through it WITHOUT changing a thing and get a friggin Run-time error 1004.
all night it has been like this.
anyone have any ideas? oh here's the code.
What do i need to add so that it selects the cell of the first instance like the functions performs when run through Excel (not a macro?)
Public Sub FindData()
Dim iCount As Integer ' counts the # of times it shows up
Dim iSiteCount As Integer ' counts the number of stores on sheet
iSiteCount = Application.WorksheetFunction.CountA(Sheets(4).Range("B:B")) ' this part works fine and returns a value of 1702
iCount = Application.CountIf(Sheets("Tank Size Info").Range("A:A"), Sheets("Form").Range("A2")) ' this part works find and retruns a value of 3
Sheets("Tank Size Info").Select ' select my target sheet to look at
MsgBox Sheets("Form").Range("A2") ' to see if what i am looking for is on the sheet...as it happens to be 68809, i took the long code out and just used the number until i can figure out the issue. Pops up 68809
MsgBox Cells.Find(What:=Sheets("Form").Range("A2"), LookAt:=xlWhole)
'Sheets("Form").Range("A2") ' also pops up 68809
Cells.Find(What:="68809", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activate 'crashes everytime
End Sub
ok, what am i doing wrong here? what am i missing or forgetting?