Need to reference macro data from a different sheet???

Mark McInerney

Active Member
Joined
Apr 4, 2012
Messages
283
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have a short macro - see below. It scans through a range of text looking for a specific string, and if found, it populates range the hits onto another column. All works well, but I need to move the data from the current worksheet to another worksheet.

The new worksheet is called "DATA".

How and where do I change the reference from a1:a1000 to the new worksheet? I have tried DATA!a1:a1000 but it is not working. Any Help appreciated - Many Thanks - Mark.

Sub FindMatches()

Range("D:D").ClearContents
Drow = 1
For Arow = 1 To 1000
If InStr(1, Cells(Arow, 1), Cells(1, 2), vbTextCompare) > 0 Then
Cells(Drow, 4).Value = Cells(Arow, 1).Value
Drow = Drow + 1
End If
Next Arow
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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