I have two columns with values (blank or characters), and I need to combine the information in those two columns into the column I'm working in. If there's only information in one of those columns, I want that information, but if there's information in both I need it to appear as "X/Y"
Examples for a given row:
Case 1: TaxableBox contains "14" and VATBox contains "1"; return "14/1"
Case 2: TaxableBox contains "" and VATBox contains "1"; return "1"
Case 3: TaxableBox contains "14" and VATBox contains ""; return "14"
Case 4: TaxableBox contains "" and VATBox contains ""; return ""
The code below worked before, but now it isn't working. I suspect It might have something to do with ActiveCell, but I'm not sure why it has a problem now when it didn't before. Any help would be appreciated.
Dim taxableBox As Range
Dim vatBox As Range
Dim i As Integer
Set taxableBox = Worksheets("VAT return layout").Range("2:2").Find("Box number, Taxable Amount")
Set vatBox = Worksheets("VAT return layout").Range("2:2").Find("Box number, VAT Amount")
Worksheets("Expected VAT return").Range("B4").Select
For i = 1 To LastRow
If [taxableBox].Offset(i, 0) <> "" And [vatBox].Offset(i, 0) <> "" Then
ActiveCell.Value = [taxableBox].Offset(i, 0) & "/" & [vatBox].Offset(i, 0)
ElseIf [taxableBox].Offset(i, 0) <> "" And [vatBox].Offset(i, 0) = "" Then
ActiveCell.Value = [taxableBox].Offset(i, 0)
ElseIf [taxableBox].Offset(i, 0) = "" And [vatBox].Offset(i, 0) <> "" Then
ActiveCell.Value = [vatBox].Offset(i, 0)
ElseIf [taxableBox].Offset(i, 0) = "" And [vatBox].Offset(i, 0) = "" Then
ActiveCell.Value = ""
End If
ActiveCell.Offset(1, 0).Select
Next i