find position of the cell with certain contents

Hans810

Board Regular
Joined
Dec 1, 2005
Messages
63
Good evening everybody,

With a for...next loop I check the cells in the range A1...AU3000 for the error content #Value!.
If the error content has been located, I want to have the feedback of the cell (eg. Z56) which was containing the error message.
Any help is very appreciated.
With regards from Veenendaal, The Netherlands.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Does this work for you?

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> test()<br><SPAN style="color:#00007F">Dim</SPAN> cell <SPAN style="color:#00007F">As</SPAN> Range<br><br><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range("A1:AU3000")<br>  <SPAN style="color:#00007F">If</SPAN> cell.Value = "#Value!" <SPAN style="color:#00007F">Then</SPAN><br>    Debug.Print cell.Address <SPAN style="color:#007F00">'ctrl + g to see outputs</SPAN><br>  <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><br><SPAN style="color:#00007F">Next</SPAN> cell<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Hi Chris,

THX it works.
What if I want to have these cell coordinates in a worksheet?
How do I come from your Debug.Print cell.Address to a Range("A10") being filled with the coordinates?

By the way, I used: If cell.Text = "#Value!" Then...

Regards,

Hans
 
Upvote 0
Found the solution (with the little help of a friend....Chris):

Sub test()
Dim cell As Range
Row = 10
For Each cell In Range("A318:AU318")
If cell.Text = "#VALUE!" Then
Debug.Print cell.Address 'ctrl + g to see outputs
Sheets("SETTINGS").Select
Range("A" & Row) = cell.Address
Row=Row+1
Sheets("DATA").Select

End If

Next cell

End Sub
 
Upvote 0
I would recommend staying away from selecting tabs and just directly state which worksheet you want to target. Here's how I would would write your solution:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> test()<br><SPAN style="color:#00007F">Dim</SPAN> cell <SPAN style="color:#00007F">As</SPAN> Range<br>Row = 10<br><br><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range("A318:AU318")<br>  <SPAN style="color:#00007F">If</SPAN> cell.Text = "#VALUE!" <SPAN style="color:#00007F">Then</SPAN><br>    Debug.Print cell.Address <SPAN style="color:#007F00">'ctrl + g to see outputs</SPAN><br>    <br>    Sheets("SETTINGS").Range("A" & Row) = cell.Address<br>    Row = Row + 1<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><br><SPAN style="color:#00007F">Next</SPAN> cell<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

Glad I was able to help you figure out your problem! :)
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,876
Members
452,363
Latest member
merico17

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