Cell Address

poitbot

New Member
Joined
Nov 22, 2006
Messages
34
Good day all,

Just wondering if there's a way to print cell addresses using a macro?

I have text that is being copied to a new worksheet from many work sheets into column A but I would like their cell locations to be printed into column B.

Possible?

Thanks,

Adam
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Yes, a Range in VBA has an Address Property
What code are you currently using to copy the values into Column "A"?

lenze
 
Upvote 0
Hey Lenze,

The code I'm using is as follows:

Public Sub texttonewsheet()
Dim n As Long, i As Long
Dim rng As range
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
n = 1
For i = 2 To Sheets.Count
For Each rng In Sheets(i).range("A1:CI200")
If rng.Value <> "" Then
If Not Application.IsNumber(rng) Then
Sheets(1).range("A" & n).Value = rng.Value
n = n + 1
End If
End If
Next rng
Next i
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
 
Upvote 0
Untested, but I thing it will work using your existing code
Rich (BB code):
Sheets(1).range("A" & n).Value = rng.Value
Sheets(1).Range("B" & n ).Value = rng.Address
n = n + 1

You can also get the Sheet Name if needed
Rich (BB code):
Sheets(1).Range("C" & n).Value = Sheets(i).Name
lenze
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,662
Members
449,462
Latest member
Chislobog

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