ItalianPlatinum
Well-known Member
- Joined
- Mar 23, 2017
- Messages
- 857
- Office Version
- 365
- 2019
- Platform
- Windows
Hello - having a stubborn issue with my VBA that I cannot quite solve for and/or maybe understanding what is going on incorrectly and looking for some guidance.
My VBA will input a formula based off data in column A as shown below. This item I am trying to solve for is say there is no data below the header (row 2), so data starting on row 3. my formula is still applying. Is anyone able to help how I can avoid this. See below for what i mean
My VBA will input a formula based off data in column A as shown below. This item I am trying to solve for is say there is no data below the header (row 2), so data starting on row 3. my formula is still applying. Is anyone able to help how I can avoid this. See below for what i mean
VBA Code:
'formatting and formulas for recon sheet
With WsNAVF
lr1 = .Cells(rows.count, "A").End(xlUp).row
If lr1 < 3 Then lr1 = 3
.Activate
.Range("A:B").RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
.Range("A:C").HorizontalAlignment = xlCenter
.Range("C3:C" & lr1).Formula = "=$A3&B3"
.Range("C3:C" & lr1).Value = .Range("C3:C" & lr1).Value
.Range("D3:D" & lr1).Formula = "=iferror(VLOOKUP(C3,'Trend_NAX'!$C$11:$E$10000,3,FALSE),"""")"
.Range("E3:E" & lr1).Formula = "=iferror(VLOOKUP(C3,'Trend'!$C$11:$F$10000,4,FALSE),"""")"
.Range("F3:F" & lr1).Formula = "=SUMIF('ACCRUAL'!$C$10:$C$10000,$A3,'ACCRUAL'!$G$10:$G$10000)"
.Range("G3:G" & lr1).Formula = "=iferror(round($F3/$E3,5),"""")"
.Range("H3:H" & lr1).Formula = "=iferror(round(($F3/$D3)*10000,2),"""")"
.Range("I3:I" & lr1).Formula = "=SUMIFS('Analysis_'!$J$10:$J$10000,'Analysis_'!$B$10:$B$10000,$A3,'Analysis_'!$D$10:$D$10000,$B3,'Analysis_'!$G$10:$G$10000,$I$1)"
.Range("J3:J" & lr1).Formula = "=iferror(round($I3/$E3,5),"""")"
.Range("K3:K" & lr1).Formula = "=iferror(round(($I3/$D3)*10000,2),"""")"
.Range("L3:L" & lr1).Formula = "=SUMIFS('Analysis_'!$J$10:$J$10000,'Analysis_'!$B$10:$B$10000,$A3,'Analysis_'!$D$10:$D$10000,$B3,'Analysis_'!$G$10:$G$10000,$L$1)"