Consulting

Results 1 to 4 of 4

Thread: I want to find first 0 in column in vba

  1. #1

    I want to find first 0 in column in vba

    hi i have sheet with 3 column, i want to find first "0" in column B and copy C1 value to A column that side of "0"
    i need vba code for this sample

    tanks

    Capture.JPG



  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Sub Test()
    
    
    Set c = Columns(2).Find(0, after:=Cells(Rows.Count, 2), lookat:=xlWhole, searchdirection:=xlNext)
    If Not c Is Nothing Then
        c.Offset(, -1) = Range("C1")
    Else
        MsgBox "0 not found"
    End If
    End Sub
    For the future, please post workbook samples (Go Advanced /Manage Attachments) rather than screenshots
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876

  4. #4
    Quote Originally Posted by mdmackillop View Post
    Sub Test()
    
    
    Set c = Columns(2).Find(0, after:=Cells(Rows.Count, 2), lookat:=xlWhole, searchdirection:=xlNext)
    If Not c Is Nothing Then
        c.Offset(, -1) = Range("C1")
    Else
        MsgBox "0 not found"
    End If
    End Sub
    For the future, please post workbook samples (Go Advanced /Manage Attachments) rather than screenshots
    tanx a lot
    now i have a different problem

    in "D1" Cell there is a value
    and i want to past C1 value to (B5 : B(D1 value))
    how can i write code?

Tags for this Thread

Posting Permissions

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