referencing cellswith values in them

Pjam

Board Regular
Joined
Jun 4, 2008
Messages
139
anyone know how to reference cells with values in them, no matter where they are on the spreadsheet?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Not sure if this is what you mean, but in VBA you could use something like this, which would select all cells with constants (text/number/errors/logical values entered manually, not using formulas) in the range A1:Z100:
Code:
Range("A1:Z100").SpecialCells(xlCellTypeConstants, 23).Select
Or this, to select all cells with formulas that result in text/numbers/errors/logicals:
Code:
Range("A1:Z100").SpecialCells(xlCellTypeFormulas, 23).Select
These perform the same function as using F5-->Special-->Constants or F5-->Special-->Formulas.
 
Upvote 0
no i dontwant to use a range, because the values could be in any cell throughout the spreadsheet, so how do i reference code to any cell in a sheet that has a value in it?

the only thing i have used so far us

For Each c In Sheets("sheet1").UsedRange.Cells<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
If Not c = Empty Then<o:p></o:p>
 
Upvote 0
Umm, then switch out Range("A1:Z100") with UsedRange

Using SpecialCells will be MUCH quicker than looping through every cell in your sheet.
 
Upvote 0
Range("A1:Z100").SpecialCells(xlCellTypeConstants, 23).Select
Range("A1:Z100").SpecialCells(xlCellTypeFormulas, 23).Select

You don't need "23" when you are referring to all types.
 
Upvote 0
Good to know, Jindon. I just copied what Excel's macro recorder spit out. I tested a few others and the number changed, so I left it. Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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