VBA to merge cell contents and copy in whole column

swapnilk

Board Regular
Joined
Apr 25, 2016
Messages
75
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi,

Can someone please make a VBA to go through all worksheets in a workbook and perform the below steps
Starting from Sheet1 (name of sheets will be random)

1. In Sheet1 add cells C2&C22&C25 and copy result (Value and not the formula) to each cell of Column A (or if possible to till the last cell with data in Column-C)
2. Each cell in Column B should have the value of A+C for eg. B1=A1&C1 ; B2=A2&C2 and so on...
3. Loop through all sheets and perform Step-1 and Step-2

Thanks in advance.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about ...
VBA Code:
Sub swapnilk()
    Dim Sht As Worksheet, lr As Long
    For Each Sht In ThisWorkbook.Worksheets
        With Sht
            lr = .Cells(.Rows.Count, "C").End(xlUp).Row
            .Range("A1:A" & lr).Value = Application.WorksheetFunction.Sum(.Range("C2,C22,C25"))
            .Range("B1").Formula = "=A1+C1"
            If lr > 1 Then
                .Range("B1").AutoFill Destination:=.Range("B1:B" & lr), Type:=xlFillDefault
            End If
        End With
    Next Sht
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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