Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Run-time error '1004'

I have a macro which accepts, through two InputBoxes, a cell address and a
value to be entered into that cell. It then sets the interior color to gold
(44). 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 second worksheet.
It then does the same with a second crossreference and the third worksheet.

The code I have is:

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).Value = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell).Interior.C olorIndex = clrGold

Worksheets("Columns").Range(Worksheets("ColumnList ").Range(SelectCell).Value)
_
.Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectCell).Interior.Colo rIndex = clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell).Value) _
.Interior.ColorIndex = clrGold

Everything seems to work fine until I try to set the cell value I have
entered the range B1 then it displays the second input box and I enter 5. At
that point I get the "Run-time error '1004'
"Application-defined or object-defined error."
It does not set cell B1 to 5 or any other displayable value. It does not set
any cell to 5.

Can you please tell me the dumb mistake I am making?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Run-time error '1004'

Hi
The syntax Range(Address) assumes that Address is a string.
Range(SelectCell) will then cause an error.
In your line
Worksheets("Columns").Range(SelectCell).Interior.C olorIndex = clrGold

If SelectCell is on Worksheets("Columns") then the syntax
SelectCell.Interior.ColorIndex = clrGold

will do the job.
If SelectCell is not on Worksheets("Columns"), or it might not be, use
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold

This second option is probably safer on the whole.

regards
Paul


On Feb 14, 5:41*am, Jerry McNabb
wrote:
I have a macro which accepts, through two InputBoxes, a cell address and a
value to be entered into that cell. It then sets the interior color to gold
(44). 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 second worksheet..
It then does the same with a second crossreference and the third worksheet..

The code I have is:

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).Value = _
* * * * * Application.InputBox(prompt:="Enter value", Type:=1)
* * Worksheets("Columns").Range(SelectCell).Interior.C olorIndex = clrGold

Worksheets("Columns").Range(Worksheets("ColumnList ").Range(SelectCell).Valu*e)
_
* * * * * .Interior.ColorIndex = clrGold
* * Worksheets("Rows").Range(SelectCell).Interior.Colo rIndex = clrGold
* * Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell).Value) _
* * * * * .Interior.ColorIndex = clrGold

Everything seems to work fine until I try to set the cell value I have
entered the range B1 then it displays the second input box and I enter 5. At
that point I get the "Run-time error '1004'
"Application-defined or object-defined error."
It does not set cell B1 to 5 or any other displayable value. It does not set
any cell to 5.

Can you please tell me the dumb mistake I am making?

Thanks.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"