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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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?
 
Upvote 0
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!!
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

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
Back
Top