ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Loop Column (https://www.excelbanter.com/excel-discussion-misc-queries/150534-loop-column.html)

Lisa

Loop Column
 
I am new to Macros in Excel can someone please help. I am trying to turn this
macro into a loop that will go from column c to column r. Now I have the same
Step copyed over and over again.

For i = 2 To 200 Step 1
e = "c" & i
x = Range(e).Interior.Color
Select Case x
Case 12632256
Range(e).Value = ""
With Range(e).Interior
.Pattern = xlNone
End With
End Select
Next
For i = 2 To 200 Step 1
e = "d" & i
x = Range(e).Interior.Color
Select Case x
Case 12632256
Range(e).Value = ""
With Range(e).Interior
.Pattern = xlNone
End With


Dana DeLouis

Loop Column
 
Not tested, but any ideas here that could help?

Sub Demo()
Const lColor As Long = 12632256
Dim Cell As Range

For Each Cell In [C2:R200].Cells
If Cells.Interior.Color = lColor Then
Cells.Value = vbNullString
Cells.Interior.Pattern = xlNone
End If
Next Cell
End Sub

--
Dana DeLouis


"Lisa" wrote in message
...
I am new to Macros in Excel can someone please help. I am trying to turn
this
macro into a loop that will go from column c to column r. Now I have the
same
Step copyed over and over again.

For i = 2 To 200 Step 1
e = "c" & i
x = Range(e).Interior.Color
Select Case x
Case 12632256
Range(e).Value = ""
With Range(e).Interior
.Pattern = xlNone
End With
End Select
Next
For i = 2 To 200 Step 1
e = "d" & i
x = Range(e).Interior.Color
Select Case x
Case 12632256
Range(e).Value = ""
With Range(e).Interior
.Pattern = xlNone
End With




Lisa

Loop Column
 
Thanks.... I'll try it

"Dana DeLouis" wrote:

Not tested, but any ideas here that could help?

Sub Demo()
Const lColor As Long = 12632256
Dim Cell As Range

For Each Cell In [C2:R200].Cells
If Cells.Interior.Color = lColor Then
Cells.Value = vbNullString
Cells.Interior.Pattern = xlNone
End If
Next Cell
End Sub

--
Dana DeLouis


"Lisa" wrote in message
...
I am new to Macros in Excel can someone please help. I am trying to turn
this
macro into a loop that will go from column c to column r. Now I have the
same
Step copyed over and over again.

For i = 2 To 200 Step 1
e = "c" & i
x = Range(e).Interior.Color
Select Case x
Case 12632256
Range(e).Value = ""
With Range(e).Interior
.Pattern = xlNone
End With
End Select
Next
For i = 2 To 200 Step 1
e = "d" & i
x = Range(e).Interior.Color
Select Case x
Case 12632256
Range(e).Value = ""
With Range(e).Interior
.Pattern = xlNone
End With






All times are GMT +1. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com