I need help convert formula to VBA Code

%3CLINGO-SUB%20id%3D%22%5C%26quot%3Blingo-sub-3151890%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3EI%20need%20help%20convert%20formula%20to%20VBA%20Code%26lt%3B%5C%2Flingo-sub%26gt%3B%3CLINGO-BODY%20id%3D%22%5C%26quot%3Blingo-body-3151890%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3E%3DIF('BYE%20WEEKS'!B2%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B2%2C%22%22)%20%3DIF('BYE%20WEEKS'!B3%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B3%2C%22%22)%20%3DIF('BYE%20WEEKS'!B4%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B4%2C%22%22)%20%3DIF('BYE%20WEEKS'!B5%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B5%2C%22%22)%20%3DIF('BYE%20WEEKS'!B6%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B6%2C%22%22)%20%3DIF('BYE%20WEEKS'!B7%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B7%2C%22%22)%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EHow%20I%20convert%20to%20vba%20code%3F%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EThanks%20You%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3ESF49ers164480%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%26lt%3B%5C%2Flingo-body%26gt%3B%3CLINGO-LABS%20id%3D%22%5C%26quot%3Blingo-labs-3151890%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3E%3CLINGO-LABEL%3EExcel%26lt%3B%5C%2Flingo-label%26gt%3B%3CLINGO-LABEL%3EMacros%20and%20VBA%26lt%3B%5C%2Flingo-label%26gt%3B%26lt%3B%5C%2Flingo-labs%26gt%3B%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3C%2FLINGO-SUB%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3151890%22%20slang%3D%22en-US%22%3EI%20need%20help%20convert%20formula%20to%20VBA%20Code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3151890%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF('BYE%20WEEKS'!B2%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B2%2C%22%22)%0A%3DIF('BYE%20WEEKS'!B3%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B3%2C%22%22)%0A%3DIF('BYE%20WEEKS'!B4%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B4%2C%22%22)%0A%3DIF('BYE%20WEEKS'!B5%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B5%2C%22%22)%0A%3DIF('BYE%20WEEKS'!B6%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B6%2C%22%22)%0A%3DIF('BYE%20WEEKS'!B7%26lt%3B%26gt%3B%22%22%2C'BYE%20WEEKS'!B7%2C%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20I%20convert%20to%20vba%20code%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20You%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESF49ers164480%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3151890%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
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

@sf49ers164480 

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

@sf49ers164480 

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.