how to select a cell with the address as string ("$D$21

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Re: how to select a cell with the address as string ("$

Is this what you mean?

=INDIRECT("$D$21")

Though, I'm guessing there is more to this question, because this would be easier:

=$D$21
 

wene

New Member
Joined
Dec 15, 2004
Messages
47
Re: how to select a cell with the address as string ("$

as you can see, i'm storing a collection of cell address in a Array as strings:
Code:
        For Each cell In Selection
            MsgBox (cell.Interior.ColorIndex)
            If cell.Interior.ColorIndex = xlColorIndexNone Then
                ArraySize = ArraySize + 1
                ReDim Preserve CellArray(ArraySize)
                CellArray(ArraySize) = cell.Address
                On Error Resume Next
                cell.Interior.ColorIndex = 2
                cell.Interior.Pattern = xlSolid
            End If
        Next cell

(..)

    Dim iterations As Integer
        iterations = 0
        While iterations < ArraySize
            iterations = iterations + 1
and now the intuitive approach to read out the Array and change the cell's color:
Code:
            cell(CellArray(iterations)).Select
            Selection.Interior.ColorIndex = 4
        Wend
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Re: how to select a cell with the address as string ("$

OK, simple example:

Code:
Sub Test()
Dim x, y As Integer
x = Array("$D$21", "$E$7")
For y = 0 To UBound(x)
Range(x(y)).Interior.ColorIndex = 4
Next y
End Sub
 

wene

New Member
Joined
Dec 15, 2004
Messages
47
Re: how to select a cell with the address as string ("$

THANKS!!!
Code:
Range(CellArray(iterations)).Select

range() accepts a string as parameter...

just perfect...
 

Forum statistics

Threads
1,147,688
Messages
5,742,629
Members
423,745
Latest member
rtaylor1987

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
Top