Run Time Error Problems

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
Hi,

Been trying all afternoon to sort this out

Here's my code:


Code:
Sheets("Sheet1").range("B5:M7").ClearContents

For irow = 5 To 7
Sheets("Sheet1").Select
strContactType = Cells(irow, 1).Value
    For icol = 2 To 13
       Sheets("Sheet1_Data").Select
       Cells(1, 1).Select
       Cells.Find(What:=strContactType, After:=ActiveCell,   LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
    iDataVal = ActiveCell.Offset(0, icol - 1).Range("a1").Value
    Sheets("Sheet1").Cells(irow, icol).Value = iDataVal
    Next
Next

Works until in can't find the strContactType - Tried with Error Handling (Removed for Code Posting) to no avail.

Any Idea's Please...!!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Richie(UK)

MrExcel MVP
Joined
May 17, 2002
Messages
3,329
Hi Michael,

Rather than activating the Find range try assigning it to a range variable. You can then test whether anything has been found by testing whether then range variable is Nothing. You can then perform the appropriate action depending on the result of your test.

What exactly are you trying to do?
 

MichaelRo

Well-known Member
Joined
Jun 7, 2004
Messages
549
Sounds like a reasonable solution - Not entirely sure how I'd do that though??

Basically - I have a list on a report (Sheet1)

I want to check if there is data available for all of the Contact Types (Columns 2-13 or Months (Jan-Dec))

If there is - transfer that information into the report sheet.

I read somewhere that the Find function retains the last search criteria and cannot be cleared, as a result throws up an error!!
 

Forum statistics

Threads
1,148,047
Messages
5,744,493
Members
423,880
Latest member
CRE_finance_guy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top