Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Macro Continuation

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Continuation


Sub LessThan1000orBlank()

Lastrow = Range(Rows.Count, "K").End(xlUp).Row

RowCount = 1
Do While RowCount <= Lastrow
If Cells(RowCount, "K") < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
RowCount = RowCount + 1

Loop
End Sub


"Beep Beep" wrote:

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Macro Continuation

Just use conditional formatting.

--
Dan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Macro Continuation

Joel it stops at the first step. Doesn't like the range object????

Lastrow = Range(Rows.Count, "K").End(xlUp).Row

"Joel" wrote:


Sub LessThan1000orBlank()

Lastrow = Range(Rows.Count, "K").End(xlUp).Row

RowCount = 1
Do While RowCount <= Lastrow
If Cells(RowCount, "K") < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
RowCount = RowCount + 1

Loop
End Sub


"Beep Beep" wrote:

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Macro Continuation

Thanks Dan, I know I could use conditional formatting, however I have around
30 worksheets in the one workbook and I want to us a Ctrl Shift Key in order
to do all 30 sheets and not have to use cf in all the sheets.

Unless we can write a macro to use conditional formatting??????

"Dan R." wrote:

Just use conditional formatting.

--
Dan




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Continuation

Sub LessThan1000orBlank()

LastRow = Range(Rows.count,"K").end(xlup).row

RowCount = 1
Do while RowCount <= Lastrow
If cells(RowCount,"K") < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
RowCount = RowCount + 1

Loop



"Beep Beep" wrote:

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Continuation

Sorry, this code is tested and works. Forgot to remove SELECTION from you
original code. Had to comment out x1solid. This format doesn't work on my
computer. It may work on yours.

"Joel" wrote:

Sub LessThan1000orBlank()

LastRow = Range(Rows.count,"K").end(xlup).row

RowCount = 1
Do while RowCount <= Lastrow
If cells(RowCount,"K") < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
RowCount = RowCount + 1

Loop



"Beep Beep" wrote:

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Macro Continuation

Joel, Thanks for your help however I keep getting the following error message
at the beginning LastRow = Range(Rows.count,"K").end(xlup).row

METHOD 'RANGE' OF OBJECT'_GLOBAL'FAILED


"Joel" wrote:

Sorry, this code is tested and works. Forgot to remove SELECTION from you
original code. Had to comment out x1solid. This format doesn't work on my
computer. It may work on yours.

"Joel" wrote:

Sub LessThan1000orBlank()

LastRow = Range(Rows.count,"K").end(xlup).row

RowCount = 1
Do while RowCount <= Lastrow
If cells(RowCount,"K") < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
RowCount = RowCount + 1

Loop



"Beep Beep" wrote:

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Continuation



"Beep Beep" wrote:

Joel, Thanks for your help however I keep getting the following error message
at the beginning LastRow = Range(Rows.count,"K").end(xlup).row

METHOD 'RANGE' OF OBJECT'_GLOBAL'FAILED


"Joel" wrote:

Sorry, this code is tested and works. Forgot to remove SELECTION from you
original code. Had to comment out x1solid. This format doesn't work on my
computer. It may work on yours.

"Joel" wrote:

Sub LessThan1000orBlank()

LastRow = Range(Rows.count,"K").end(xlup).row

RowCount = 1
Do while RowCount <= Lastrow
If cells(RowCount,"K") < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
RowCount = RowCount + 1

Loop



"Beep Beep" wrote:

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Continuation

Sorry again. I thought I fixed this line
from
LastRow = Range(Rows.count,"K").end(xlup).row
to
LastRow = cells(Rows.count,"K").end(xlup).row

"Beep Beep" wrote:

Joel, Thanks for your help however I keep getting the following error message
at the beginning LastRow = Range(Rows.count,"K").end(xlup).row

METHOD 'RANGE' OF OBJECT'_GLOBAL'FAILED


"Joel" wrote:

Sorry, this code is tested and works. Forgot to remove SELECTION from you
original code. Had to comment out x1solid. This format doesn't work on my
computer. It may work on yours.

"Joel" wrote:

Sub LessThan1000orBlank()

LastRow = Range(Rows.count,"K").end(xlup).row

RowCount = 1
Do while RowCount <= Lastrow
If cells(RowCount,"K") < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
RowCount = RowCount + 1

Loop



"Beep Beep" wrote:

The below macro works ok, however it neither color's the cell and also I
would like the macro to continue on after finding one cell with less than
1,000 or blank. Currently it stops at the first cell it finds with this
criteria. There could be multiple cells that fall under this criteria.

Sub LessThan1000orBlank()

Range("K1").Select

Do Until ActiveCell < 1000
If ActiveCell < 1000 Then
With Selection.Interior
.ColorIndex = 6
.Pattern = x1solid
End With

End If
ActiveCell.Offset(1, 0).Select


Loop

End Sub



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Macro Continuation

On Aug 15, 11:14 am, Beep Beep
wrote:
Thanks Dan, I know I could use conditional formatting, however I have around
30 worksheets in the one workbook and I want to us a Ctrl Shift Key in order
to do all 30 sheets and not have to use cf in all the sheets.

Unless we can write a macro to use conditional formatting??????


Sure can:


Sub LessThan1000orBlank()
Dim i As Integer

For i = 1 To Worksheets.Count
With Sheets(i).Columns("K")
.FormatConditions.Add _
Type:=xlCellValue, _
Operator:=xlLess, _
Formula1:="1000"
.FormatConditions(1).Interior _
.ColorIndex = 6
End With
Next i
End Sub


--
Dan

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
Continuation of a macro Dan Wood Excel Discussion (Misc queries) 2 December 20th 09 11:54 AM
Line Continuation issue Bishop Excel Worksheet Functions 6 May 21st 09 01:47 PM
formula continuation with the paint too. Fay New Users to Excel 2 March 17th 08 10:56 PM
continuation from yesterday Mindy Excel Discussion (Misc queries) 4 June 22nd 06 11:13 PM
Continuation of the listbox question Brad K. Excel Programming 1 December 17th 04 05:50 AM


All times are GMT +1. The time now is 02:33 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"