I need help convert formula to VBA Code

Iron Contributor
=IF('BYE WEEKS'!B2<>"",'BYE WEEKS'!B2,"")


=IF('BYE WEEKS'!B3<>"",'BYE WEEKS'!B3,"")


=IF('BYE WEEKS'!B4<>"",'BYE WEEKS'!B4,"")


=IF('BYE WEEKS'!B5<>"",'BYE WEEKS'!B5,"")


=IF('BYE WEEKS'!B6<>"",'BYE WEEKS'!B6,"")


=IF('BYE WEEKS'!B7<>"",'BYE WEEKS'!B7,"")

How I convert to vba code?

 

Thanks You

 

SF49ers164480

 

3 Replies

@sf49ers19238597 

Sub bye_weeks()

Dim i As Integer

For i = 2 To 7

If Sheets("bye weeks").Cells(i, 2).Value <> "" Then
Cells(i, 2).Value = Sheets("bye weeks").Cells(i, 2).Value
Else
Cells(i, 2).Value = ""
End If
 
Next i
End Sub

 

Maybe with this code.

Code do not work

 

 

 

How make a simple code

@sf49ers19238597 

Does it work for you if you click the button in cell D2? These lines of code are the easiest way i can suggest to put your formulas into VBA and it works perfectly in my spreadsheet.