View Full Version : Solved: not every cell but every i cel
domm1988
07-10-2012, 01:11 AM
i want my macro to color not every cell but make gap between colored in size of i (cells)
Any idea. I thought to change for loop insted of for each use something else but i dont think its possible
Sub dfghdfgh()
Dim i As Integer
Dim area, cell As Range
Dim j As
Integer
i = InputBox("Give the value of i")
Set area =
Application.InputBox("Select range", "Range", , , , , , 8)
For Each cell In area
area.Interior.Color = RGB(200, 160, 35)
Next cell
End Sub
Bob Phillips
07-10-2012, 02:20 AM
Sub dfghdfgh()
Dim i As Long
Dim area As Range
Dim j As Long
i = InputBox("Give the value of i")
Set area = Application.InputBox("Select range", "Range", , , , , , 8)
For j = 1 To area.Rows.Count Step i
area.Cells(j, 1).Interior.Color = RGB(200, 160, 35)
Next cell
End Sub
nick_k
07-10-2012, 02:25 AM
thre should be j instead of cell after next
But thanks a lot now i need whole range not only one column i will think about it
nick_k
07-10-2012, 02:27 AM
it makes one row now and one column
How to make it work for whole selected rectangle
Sub fsdfgs()
Dim i As Long
Dim area As Range
Dim j As Long
Dim k As Long
i = InputBox("Give the value of i")
Set area = Application.InputBox("Select range", "Range", , , , , , 8)
For j = 1 To area.Rows.Count Step i
area.Cells(j, 1).Interior.Color = RGB(200, 160, 35)
Next j
For k = 1 To area.Rows.Count Step i
area.Cells(1, k).Interior.Color = RGB(200, 160, 35)
Next k
End Sub
nick_k,
I will be the first to apologize if my bleary eyes are just reading this wrong, but gosh, you sound at #3 as if you are domm1988 following up?
Mark
nick_k
07-10-2012, 03:03 AM
Yep i am both :)
I forget my password and then it had to log me in automaticly after i created new account
Bob Phillips
07-10-2012, 04:12 AM
Sub fsdfgs()
Dim i As Long
Dim area As Range
Dim j As Long
Dim k As Long
i = InputBox("Give the value of i")
Set area = Application.InputBox("Select range", "Range", , , , , , 8)
For j = 1 To area.Rows.Count Step i
For k = 1 To area.Columns.Count Step i
area.Cells(j, k).Interior.Color = RGB(200, 160, 35)
Next k
Next j
End Sub
nick_k
07-10-2012, 04:45 AM
Thank You
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.