Application.CutCopyMode=False on inactive sheet

Millsio88

New Member
Joined
May 1, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

Newbie to VBA and I'm struggling to resolve an issue. I'm running a module with a button on sheet 1 it copies data to sheet 2 & 3 when it gets to the last copies (Bold) the range remains highlighted on the sheets 2 & 3. I've tried using Application.CutCopyMode = False which only seem to work when the sheet is active. My only way around so far that I've found online is using a 'With' (Below) but i don't want the macro to select sheet 2, then sheet 3, to then select sheet1 at the end.

The result I would like is, once the Marco is complete, on both sheet 2 and 3 the next available cell in column A is selected - not the last data that was copied to them.

With Sheets("Data Log")
.Select
.Range("A1").select
End With

Any assistance would be great.

***Code***

Sub CopySource()
Dim rngSource As Range
Dim rngTarget As Range
Dim iRow As Integer

'Data
'start new row
iRow = Worksheets("Data Log").Cells(Rows.Count, 1).End(xlUp).Row + 1

Set rngSource = Worksheets("Submit Form2").Range("H9:H18")
Set rngTarget = Worksheets("Data Log").Range("A" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=True

Set rngSource = Worksheets("Submit Form2").Range("E25:M25")
Set rngTarget = Worksheets("Data Log").Range("L" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues

Set rngSource = Worksheets("Submit Form2").Range("E30:K30")
Set rngTarget = Worksheets("Data Log").Range("U" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues

Set rngSource = Worksheets("Submit Form2").Range("E35:I35")
Set rngTarget = Worksheets("Data Log").Range("AB" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues

Set rngSource = Worksheets("Submit Form2").Range("E40:M40")
Set rngTarget = Worksheets("Data Log").Range("AG" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues

Set rngSource = Worksheets("Submit Form2").Range("Q8:Q20")
Set rngTarget = Worksheets("Data Log").Range("AP" & iRow)
rngSource.Copy

rngTarget.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=True

'start new row
iRow = Worksheets("Reg Log").Cells(Rows.Count, 1).End(xlUp).Row + 1

'Actions with transpose
Set rngSource = Worksheets("Submit Form2").Range("H9:H18")
Set rngTarget = Worksheets("Reg Log").Range("A" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=True

Set rngSource = Worksheets("Submit Form2").Range("E26:M26")
Set rngTarget = Worksheets("Reg Log").Range("L" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues

Set rngSource = Worksheets("Submit Form2").Range("E31:K31")
Set rngTarget = Worksheets("Reg Log").Range("U" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues

Set rngSource = Worksheets("Submit Form2").Range("E36:I36")
Set rngTarget = Worksheets("Reg Log").Range("AB" & iRow)
rngSource.Copy
rngTarget.PasteSpecial Paste:=xlPasteValues

Set rngSource = Worksheets("Submit Form2").Range("E41:M41")
Set rngTarget = Worksheets("Reg Log").Range("AG" & iRow)
rngSource.Copy

rngTarget.PasteSpecial Paste:=xlPasteValues

End Sub
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,264
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
Try it like
VBA Code:
Sub CopySource()
   Dim wsData As Worksheet
   Dim iRow As Long

   Set wsData = Sheets("Submit Form2")

   With Worksheets("Data Log")
      iRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
      .Range("A" & iRow).Resize(, 2).Value = Application.Transpose(wsData.Range("H9:H18").Value)
      .Range("L" & iRow).Resize(, 9).Value = wsData.Range("E25:M25").Value
      .Range("U" & iRow).Resize(, 7).Value = wsData.Range("E30:K30").Value
      .Range("AB" & iRow).Resize(, 5).Value = wsData.Range("E35:I35").Value
      .Range("AG" & iRow).Resize(, 9).Value = wsData.Range("E40:M40").Value
      .Range("AP" & iRow).Resize(, 13).Value = Application.Transpose(wsData.Range("Q8:Q20").Value)
   End With
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,264
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,035
Messages
5,622,332
Members
415,894
Latest member
silverhaze

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
Top