ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I have the following code but a bit long winded.
Can you please advise how it can be simplified to run smoother / lag free.
Thanks
Can you please advise how it can be simplified to run smoother / lag free.
Thanks
Rich (BB code):
Private Sub PasteIfFormulas_Click()
Dim WS As Worksheet
Set WS = Worksheets("INV")
WS.Range("G14").Formula = "=IFERROR(IF(INDEX(DATABASE!R:R,$H$13)=0,"""",INDEX(DATABASE!R:R,$H$13)),"""")"
WS.Range("G14").Formula = "=IFERROR(IF(INDEX(DATABASE!R:R,$H$13)=0,"""",INDEX(DATABASE!R:R,$H$13)),"""")"
WS.Range("G15").Formula = "=IFERROR(IF(INDEX(DATABASE!S:S,$H$13)=0,"""",INDEX(DATABASE!S:S,$H$13)),"""")"
WS.Range("G16").Formula = "=IFERROR(IF(INDEX(DATABASE!T:T,$H$13)=0,"""",INDEX(DATABASE!T:T,$H$13)),"""")"
WS.Range("G17").Formula = "=IFERROR(IF(INDEX(DATABASE!U:U,$H$13)=0,"""",INDEX(DATABASE!U:U,$H$13)),"""")"
WS.Range("G18").Formula = "=IFERROR(IF(INDEX(DATABASE!V:V,$H$13)=0,"""",INDEX(DATABASE!V:V,$H$13)),"""")"
WS.Range("L14").Formula = "=IFERROR(IF(INDEX(DATABASE!D:D,$H$13)=0,"""",INDEX(DATABASE!D:D,$H$13)),"""")"
WS.Range("L15").Formula = "=IFERROR(IF(INDEX(DATABASE!B:B,$H$13)=0,"""",INDEX(DATABASE!B:B,$H$13)),"""")"
WS.Range("L16").Formula = "=IFERROR(IF(INDEX(DATABASE!L:L,$H$13)=0,"""",INDEX(DATABASE!L:L,$H$13)),"""")"
WS.Range("L17").Formula = "=IFERROR(IF(INDEX(DATABASE!W:W,$H$13)=0,"""",INDEX(DATABASE!W:W,$H$13)),"""")"
WS.Range("M27").Formula = "=IF(AND(H27="""",H27=""""),"""",H27*J27)"
WS.Range("M28").Formula = "=IF(AND(H28="""",H28=""""),"""",H28*J28)"
WS.Range("M29").Formula = "=IF(AND(H29="""",H29=""""),"""",H29*J29)"
WS.Range("M30").Formula = "=IF(AND(H30="""",H30=""""),"""",H30*J30)"
WS.Range("M31").Formula = "=IF(AND(H31="""",H31=""""),"""",H31*J31)"
WS.Range("M32").Formula = "=IF(AND(H32="""",H32=""""),"""",H32*J32)"
WS.Range("M33").Formula = "=IF(AND(H33="""",H33=""""),"""",H33*J33)"
WS.Range("M34").Formula = "=IF(AND(H34="""",H34=""""),"""",H34*J34)"
WS.Range("M35").Formula = "=IF(AND(H35="""",H35=""""),"""",H35*J35)"
WS.Range("M36").Formula = "=IF(AND(H36="""",H36=""""),"""",H36*J36)"
End Sub