how to substract merged columns and result would be also in merged cells.

Shaikh Aziz

New Member
Joined
Dec 18, 2020
Messages
35
Office Version
  1. 2007
Platform
  1. Windows
Dear Everyone,

I have below general query, i have some merged numerice values in ColumnK & ColumnO and i want to substract columnO - ColumnK = ColumnP merged output should be comes in columnP, as please note i have actual vba data set and i have to append future suggested codes into that actual data set.

Please find attached screenshot for better understanding the query.

and thankyou for lookin
smile.gif


and PFB cross-posted links, as still finding for an answer
 

Attachments

  • Capture3.JPG
    Capture3.JPG
    27.3 KB · Views: 4

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try this:
VBA Code:
Sub CalculateMerged3rows()
    Dim Lr As Long
    Dim i As Long
Lr = Cells(Rows.Count, 11).End(xlUp).Row + 3
For i = 1 To Lr / 3
Range("P" & i * 3 - 2).Value = Range("O" & i * 3 - 2).Value - Range("K" & i * 3 - 2).Value
Next i
End Sub
 
Upvote 0
Try this:
VBA Code:
Sub CalculateMerged3rows()
    Dim Lr As Long
    Dim i As Long
Lr = Cells(Rows.Count, 11).End(xlUp).Row + 3
For i = 1 To Lr / 3
Range("P" & i * 3 - 2).Value = Range("O" & i * 3 - 2).Value - Range("K" & i * 3 - 2).Value
Next i
End Sub
thankyou so much :)
 
Upvote 0
Try
VBA Code:
Sub test()
    Dim a1, a2, af
    
    With Sheets("Sheet1")
        With .[k1].CurrentRegion
            a1 = .Offset(1).Resize(.Rows.Count - 1).Value
        End With
        With .[o1].CurrentRegion
            a2 = .Offset(1).Resize(.Rows.Count - 1).Value
        End With
        ReDim af(1 To UBound(a1))
        For i = 1 To UBound(a1)
            If a1(i, 1) <> "" Then
                af(i) = a2(i, 1) - a1(i, 1)
            End If
        Next
        .[p2].Resize(UBound(a1)) = Application.Transpose(af)
    End With
End Sub
 
Upvote 0
Solution
Try
VBA Code:
Sub test()
    Dim a1, a2, af
   
    With Sheets("Sheet1")
        With .[k1].CurrentRegion
            a1 = .Offset(1).Resize(.Rows.Count - 1).Value
        End With
        With .[o1].CurrentRegion
            a2 = .Offset(1).Resize(.Rows.Count - 1).Value
        End With
        ReDim af(1 To UBound(a1))
        For i = 1 To UBound(a1)
            If a1(i, 1) <> "" Then
                af(i) = a2(i, 1) - a1(i, 1)
            End If
        Next
        .[p2].Resize(UBound(a1)) = Application.Transpose(af)
    End With
End Sub
thankyou so much it's something very new to learn & practice and it's worked. thankyou so much
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top