Results 1 to 3 of 3

Thread: VB/Excel Find first empty cell ina column

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2009
    Posts
    1

    VB/Excel Find first empty cell ina column

    Hi there!

    Hope you can help me.

    I have column "A" with 6000 rows containing data.
    A1 to A6000.
    But not all rows contains data. Some are empty.

    Now i want a code that goes from first row to row 6000 and fill the empty cells with a value from an another cell in the row.

    For example
    A1=3
    A2=4
    A3=15
    A4 is blank. In a4 i want the value from d4-e4.

    Hope you understand.

    Thanks Sverker

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: VB/Excel Find first empty cell ina column

    Thread moved to Office Development/VBA forum (note that the "VB Editor" in Office programs is actually VBA rather than VB, so the VB6 forum is not really apt)

  3. #3
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: VB/Excel Find first empty cell ina column

    This is not the fastest way but it is easy for you to understand:
    Code:
    Sub xx()
        Dim r As Long
        
        For r = 1 To 6000
            If Cells(r, 1) = "" Then
                Cells(r, 1) = Cells(r, 4) - Cells(r, 5)
            End If
        Next
    End Sub
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Posting Permissions

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



Click Here to Expand Forum to Full Width