PDA

View Full Version : I want to find first 0 in column in vba



ma.afsharpey
11-08-2017, 04:31 AM
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

20883

mdmackillop
11-08-2017, 04:44 AM
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

p45cal
11-08-2017, 05:53 AM
cross post:
https://stackoverflow.com/q/47175701

ma.afsharpey
11-08-2017, 11:19 AM
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:banghead:

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