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

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).Va lue = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Inter ior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Col or = clrGold
Worksheets("Areas").Range(SelectCell.Address).Inte rior.ColorIndex = clrGold

Worksheets("Areas").Range(Worksheets("AreaList").R ange(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.ColorIn dex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".

Can someone help me?

Thank you.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Run-time error 1004


"SelectCell.Adddress is set to B1 and its value is set to 5"

So this...
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = "clrGold"

Equals this ?...
Worksheets("Columns").Range(5).Interior.ColorIndex = "clrGold"

Which sheet is doing what to whom is difficult to determine,
but it appears you can remove ".Value" and it should work.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Jerry McNabb"
wrote in message
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).Va lue = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Inter ior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Col or = clrGold
Worksheets("Areas").Range(SelectCell.Address).Inte rior.ColorIndex = clrGold

Worksheets("Areas").Range(Worksheets("AreaList").R ange(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.ColorIn dex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Run-time error 1004

You're a good man Jim Cone, I sure couldn't decipher it, but the Value part
didn't make sense to me either. I was also wondering if there shouldn't be a
comma after the Worksheets("ColumnList") clause. I just couldn't see where a
range was defined.

"Jim Cone" wrote:


"SelectCell.Adddress is set to B1 and its value is set to 5"

So this...
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = "clrGold"

Equals this ?...
Worksheets("Columns").Range(5).Interior.ColorIndex = "clrGold"

Which sheet is doing what to whom is difficult to determine,
but it appears you can remove ".Value" and it should work.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Jerry McNabb"
wrote in message
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).Va lue = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Inter ior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Col or = clrGold
Worksheets("Areas").Range(SelectCell.Address).Inte rior.ColorIndex = clrGold

Worksheets("Areas").Range(Worksheets("AreaList").R ange(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.ColorIn dex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Run-time error 1004

Thanks a bunch guys. I'll try that.

"JLGWhiz" wrote:

You're a good man Jim Cone, I sure couldn't decipher it, but the Value part
didn't make sense to me either. I was also wondering if there shouldn't be a
comma after the Worksheets("ColumnList") clause. I just couldn't see where a
range was defined.

"Jim Cone" wrote:


"SelectCell.Adddress is set to B1 and its value is set to 5"

So this...
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = "clrGold"

Equals this ?...
Worksheets("Columns").Range(5).Interior.ColorIndex = "clrGold"

Which sheet is doing what to whom is difficult to determine,
but it appears you can remove ".Value" and it should work.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Jerry McNabb"
wrote in message
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).Va lue = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Inter ior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Col or = clrGold
Worksheets("Areas").Range(SelectCell.Address).Inte rior.ColorIndex = clrGold

Worksheets("Areas").Range(Worksheets("AreaList").R ange(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.ColorIn dex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Run-time error 1004

Remember, SelectCell's address = B1. At this time Columns!$B$1 = 5 and
ColumnList!$B$1 = "W1:AF1". I want to set the interior color index of
Columns!W1:AF1 to gold (44).

"JLGWhiz" wrote:

You're a good man Jim Cone, I sure couldn't decipher it, but the Value part
didn't make sense to me either. I was also wondering if there shouldn't be a
comma after the Worksheets("ColumnList") clause. I just couldn't see where a
range was defined.

"Jim Cone" wrote:


"SelectCell.Adddress is set to B1 and its value is set to 5"

So this...
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = "clrGold"

Equals this ?...
Worksheets("Columns").Range(5).Interior.ColorIndex = "clrGold"

Which sheet is doing what to whom is difficult to determine,
but it appears you can remove ".Value" and it should work.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Jerry McNabb"
wrote in message
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).Va lue = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Inter ior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Col or = clrGold
Worksheets("Areas").Range(SelectCell.Address).Inte rior.ColorIndex = clrGold

Worksheets("Areas").Range(Worksheets("AreaList").R ange(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.ColorIn dex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Run-time error 1004

Sorry, with .value deleted, I got the same error.

Remember, SelectCell's address = B1. At this time Columns!$B$1 = 5 and
ColumnList!$B$1 = "W1:AF1". I want to set the interior color index of
Columns!W1:AF1 to gold (44).

"Jim Cone" wrote:


"SelectCell.Adddress is set to B1 and its value is set to 5"

So this...
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = "clrGold"

Equals this ?...
Worksheets("Columns").Range(5).Interior.ColorIndex = "clrGold"

Which sheet is doing what to whom is difficult to determine,
but it appears you can remove ".Value" and it should work.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Jerry McNabb"
wrote in message
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).Va lue = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Inter ior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Col or = clrGold
Worksheets("Areas").Range(SelectCell.Address).Inte rior.ColorIndex = clrGold

Worksheets("Areas").Range(Worksheets("AreaList").R ange(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.ColorIn dex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Run-time error 1004

Pardon me if I am repeating myself, but my first attempt at posting this
didn't seem to work.

With .Value deleted, I got the same error message.

Remember, SelectCell's address = B1. At this time Columns!$B$1 = 5 and
ColumnList!$B$1 = "W1:AF1". I want to set the interior color index of
Columns!W1:AF1 to gold (44). Is worksheets("ColumnList").Range(SelectCell)
not = ColumnList!B1?

"Jim Cone" wrote:


"SelectCell.Adddress is set to B1 and its value is set to 5"

So this...
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = "clrGold"

Equals this ?...
Worksheets("Columns").Range(5).Interior.ColorIndex = "clrGold"

Which sheet is doing what to whom is difficult to determine,
but it appears you can remove ".Value" and it should work.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Jerry McNabb"
wrote in message
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).Va lue = _
Application.InputBox(prompt:="Enter value", Type:=1)
Worksheets("Columns").Range(SelectCell.Address).In terior.ColorIndex =
clrGold
Worksheets("Columns").Range(Worksheets("ColumnList ") _
.Range(SelectCell.Address).Value).Interior.ColorIn dex = clrGold
Worksheets("Rows").Range(SelectCell.Address).Inter ior.ColorIndex =
clrGold
Worksheets("Rows").Range(Worksheets("RowList").Ran ge(SelectCell.Address) _
.Value).Interior.ColorIndex = clrGold
Worksheets("Rows").Range(SelectRange).Interior.Col or = clrGold
Worksheets("Areas").Range(SelectCell.Address).Inte rior.ColorIndex = clrGold

Worksheets("Areas").Range(Worksheets("AreaList").R ange(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.ColorIn dex = clrGold
returns a "Run-Time Error '1004'
"Application-Defined or Object-Defined Error".
Can someone help me?
Thank you.


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 Object defined error [email protected] Excel Programming 1 May 15th 07 03:31 AM
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


All times are GMT +1. The time now is 09:39 AM.

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"