Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default I had this working a few days ago but now cannot get it to run

jlgwhiz or mike H helped me out with this awhile ago. Well, for lack of a
better excuse I lost some data and had to start over. Now I cannot get this
to work and cannot figure out why. I am getting a variable not defined error.

Sub ConcatColor()
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow '<<assumes header row
If range("P" & i).Interior.ColorIndex = 3 Then
range("P" & i) = Cells(i, 7) & Cells(i, 8) & Cells(i, 9)
End If
Next
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default I had this working a few days ago but now cannot get it to run

Hi,

It sounds like you have Option Explicit set and therefore all variables must
be dimensioned. Try this

Sub ConcatColor()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow '<<assumes header row
If Range("P" & i).Interior.ColorIndex = 3 Then
Range("P" & i) = Cells(i, 7) & Cells(i, 8) & Cells(i, 9)
End If
Next
End Sub

"jeremiah" wrote:

jlgwhiz or mike H helped me out with this awhile ago. Well, for lack of a
better excuse I lost some data and had to start over. Now I cannot get this
to work and cannot figure out why. I am getting a variable not defined error.

Sub ConcatColor()
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow '<<assumes header row
If range("P" & i).Interior.ColorIndex = 3 Then
range("P" & i) = Cells(i, 7) & Cells(i, 8) & Cells(i, 9)
End If
Next
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default I had this working a few days ago but now cannot get it to run

Thanks, I had given that some thought but am not quite familiar enough with
vb to give it a go on my own. Thanks again, it does work now.

"Mike H" wrote:

Hi,

It sounds like you have Option Explicit set and therefore all variables must
be dimensioned. Try this

Sub ConcatColor()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow '<<assumes header row
If Range("P" & i).Interior.ColorIndex = 3 Then
Range("P" & i) = Cells(i, 7) & Cells(i, 8) & Cells(i, 9)
End If
Next
End Sub

"jeremiah" wrote:

jlgwhiz or mike H helped me out with this awhile ago. Well, for lack of a
better excuse I lost some data and had to start over. Now I cannot get this
to work and cannot figure out why. I am getting a variable not defined error.

Sub ConcatColor()
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow '<<assumes header row
If range("P" & i).Interior.ColorIndex = 3 Then
range("P" & i) = Cells(i, 7) & Cells(i, 8) & Cells(i, 9)
End If
Next
End Sub

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
Sum working days NM Excel Worksheet Functions 13 December 11th 08 07:48 PM
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Making weekend days working days - the system cuts the working tim Fluffy Excel Discussion (Misc queries) 1 May 30th 08 10:02 PM
How to calculation no. of days (only working days) between two dat Vivian Chan Excel Discussion (Misc queries) 1 July 26th 07 09:16 AM
Working Days Jez[_7_] Excel Programming 2 June 28th 06 09:30 PM


All times are GMT +1. The time now is 11:52 AM.

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

About Us

"It's about Microsoft Excel"