Merge two Macros

Rubber Beaked Woodpecker

Board Regular
Joined
Aug 30, 2015
Messages
203
Office Version
  1. 2021
The following Macro works very well

VBA Code:
Sub logBalance()
   
Dim source As Worksheet
Dim destination As Worksheet
Dim emptyColumn As Long

Set source = Sheets("Sheet1")
Set destination = Sheets("Sheet1")

source.Range("o5:o16").Copy

emptyColumn = destination.Cells(5, destination.Columns.Count).End(xlToLeft).Column

If IsEmpty(destination.Range("X5")) Then
destination.Cells(1, 1).PasteSpecial Transpose:=True
Else
emptyColumn = emptyColumn + 1
destination.Cells(5, emptyColumn).PasteSpecial Transpose:=False
Application.CutCopyMode = False


End If

End Sub

However after it has executed I would also like the following code to run.
I've tried several ways but cannot get this work.
Any ideas please?

Code:
Range("S1").Select
    Selection.Copy
    Range("T1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi, It would be good if you show the data also.

meanwhile you can simple copy the below code within the subprocedure.

VBA Code:
Sub logBalance()
   
Dim source As Worksheet
Dim destination As Worksheet
Dim emptyColumn As Long

Set source = Sheets("Sheet1")
Set destination = Sheets("Sheet1")

source.Range("o5:o16").Copy

emptyColumn = destination.Cells(5, destination.Columns.Count).End(xlToLeft).Column

If IsEmpty(destination.Range("X5")) Then
    destination.Cells(1, 1).PasteSpecial Transpose:=True
Else
    emptyColumn = emptyColumn + 1
    destination.Cells(5, emptyColumn).PasteSpecial Transpose:=False
    Application.CutCopyMode = False
End If

    Range("S1").Copy
    Range("T1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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