J
Jerry McNabb
The following macro is intended to accept, through two InputBoxes, a cell
address and a value to be entered into that cell. It then sets the interior
color to gold. It then looks into a cross reference matrix. Each cell in the
matrix contains a range of addresses in the format "L1:U1". It then sets the
interior colors of the ten cells in that range within the first worksheet.
It then does the same with a second crossreference and the second worksheet
and again with the third.
Sub Initialize()
Dim clrGold As Integer
Dim SelectCell As Range
clrGold = Worksheets("Columns").Cells(13, 2).Interior.ColorIndex
Set SelectCell = Application.InputBox(prompt:="Select a cell", Type:=8)
Worksheets("Columns").Range(SelectCell.Address).Value = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).Interior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList") _
.Range(SelectCell.Address).Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Interior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Range(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Color = clrGold
Worksheets("Areas").Range(SelectCell.Address).Interior.ColorIndex = clrGold
Worksheets("Areas").Range(Worksheets("AreaList").Range(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
End Sub
When I try to run it. Everything seems fine. clrGold is set to 44.
SelectCell.Adddress is set to B1 and its value is set to 5. Columns!$B$1 gets
set to 5 and its color is set to gold, just as expected. ColumnList!$B$1
contains "W1:AF1". The instruction
Worksheets("Columns").Range(Worksheets("ColumnList") _
.Range(SelectCell.Address).Value).Interior.ColorIndex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.
address and a value to be entered into that cell. It then sets the interior
color to gold. It then looks into a cross reference matrix. Each cell in the
matrix contains a range of addresses in the format "L1:U1". It then sets the
interior colors of the ten cells in that range within the first worksheet.
It then does the same with a second crossreference and the second worksheet
and again with the third.
Sub Initialize()
Dim clrGold As Integer
Dim SelectCell As Range
clrGold = Worksheets("Columns").Cells(13, 2).Interior.ColorIndex
Set SelectCell = Application.InputBox(prompt:="Select a cell", Type:=8)
Worksheets("Columns").Range(SelectCell.Address).Value = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).Interior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList") _
.Range(SelectCell.Address).Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Interior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Range(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Color = clrGold
Worksheets("Areas").Range(SelectCell.Address).Interior.ColorIndex = clrGold
Worksheets("Areas").Range(Worksheets("AreaList").Range(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
End Sub
When I try to run it. Everything seems fine. clrGold is set to 44.
SelectCell.Adddress is set to B1 and its value is set to 5. Columns!$B$1 gets
set to 5 and its color is set to gold, just as expected. ColumnList!$B$1
contains "W1:AF1". The instruction
Worksheets("Columns").Range(Worksheets("ColumnList") _
.Range(SelectCell.Address).Value).Interior.ColorIndex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.