Consulting

Results 1 to 8 of 8

Thread: Solved: not every cell but every i cel

  1. #1
    Banned VBAX Regular
    Joined
    May 2012
    Posts
    11
    Location

    Solved: not every cell but every i cel

    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

    [VBA]

    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
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]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
    [/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jul 2012
    Posts
    7
    Location
    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

  4. #4
    VBAX Regular
    Joined
    Jul 2012
    Posts
    7
    Location
    it makes one row now and one column
    How to make it work for whole selected rectangle
    [vba]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[/vba]

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    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

  6. #6
    VBAX Regular
    Joined
    Jul 2012
    Posts
    7
    Location
    Yep i am both
    I forget my password and then it had to log me in automaticly after i created new account

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]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[/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    VBAX Regular
    Joined
    Jul 2012
    Posts
    7
    Location
    Thank You

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •