+ Reply to Thread
Results 1 to 4 of 4

For Each Cell In Range

Hybrid View

rename For Each Cell In Range 01-10-2013, 12:20 AM
domfootwear Re: For Each Cell In Range 01-10-2013, 12:30 AM
rename Re: For Each Cell In Range 01-10-2013, 12:35 AM
nilem Re: For Each Cell In Range 01-10-2013, 01:03 AM
  1. #1
    Registered User
    Join Date
    11-13-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2003, 2010
    Posts
    73

    For Each Cell In Range

    Hi all. Just one question. Is it possible to use "for each cell in range" if range is not together? Example Cell A1, A5, A10 Etc..
    If so , how do i set the range for these cells? i need to check if these cells is empty, if not empty cell.value = 1. Cells is in offset of (0,5) Thanks very much!!

  2. #2
    Registered User
    Join Date
    01-09-2013
    Location
    Vietnam
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: For Each Cell In Range

    Quote Originally Posted by rename View Post
    Hi all. Just one question. Is it possible to use "for each cell in range" if range is not together? Example Cell A1, A5, A10 Etc..
    If so , how do i set the range for these cells? i need to check if these cells is empty, if not empty cell.value = 1. Cells is in offset of (0,5) Thanks very much!!
    You should put the range into array and after that you loop throught that array.
    Try it.

  3. #3
    Registered User
    Join Date
    11-13-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2003, 2010
    Posts
    73

    Re: For Each Cell In Range

    you mean named range? But i've many rows to check which means i'll have to add each row in a named range?

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: For Each Cell In Range

    maybe something like this
    Dim r As Range
    For Each r In Range("A1,A5,A10,A15,A20")
        If Not IsEmpty(r) Then r.Value = 1
    Next r
    or
    On Error Resume Next
    Range("A1,A5,A10,A15,A20").SpecialCells(xlCellTypeConstants).Value = 1
    On Error GoTo 0
    or
    Dim i As Long
    For i = 5 To 20 Step 5
        If Not IsEmpty(Cells(i, 1)) Then Cells(i, 1) = 1
    Next i

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1