Help with VBA code - More to paste & pressing enter after a paste is complete

KiloHotel

New Member
Joined
Feb 4, 2018
Messages
42
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
Hi guys,

I am running this code;


VBA Code:
Sub
Dim lngMax As Long
Dim lngcounter As Long
Dim lngCalc As Long

lngCalc = Application.Calculation
Application.Calculation = xlCalculationManual
With ActiveSheet
  lngMax = WorksheetFunction.Max(.Range("B" & .Rows.Count).End(xlUp).Row, .Range("C" & .Rows.Count).End(xlUp).Row)
  For lngcounter = 5 To lngMax
    If UCase(.Cells(lngcounter, "B").Value) = "HERE" Then
      .Rows(4).Copy .Rows(lngcounter)
    End If
  Next lngcounter
End With
Application.Calculation = lngCalc
End Sub


My issue is when it pastes the row, in column F of that pasted row I have a formula also pasted however, When the line pastes it does paste in the I have to click each pasted column F cell and just press enter for excel to act on the formula input.

I am sure it is very simple but I cannot wrap my head around it, I have tried adding .Select in and also Range("F6").Select
 
Last edited by a moderator:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Maybe try a forced recalculation. Not an Excel vba expert but I suspect when you turn calc off then edit then turn back on, it needs another edit or similar event in order to calculate. So before end sub, maybe put
Activesheet.Calculate
 
Upvote 0
Could it be that at some point your code errored before it got to the line near the end that resets the calculation to (presumably) Automatic?
If so, that would leave the calculation mode as Manual.
Next time the code runs it would be
  • recorded as Manual by lngCalc = Application.Calculation
  • set to Manual by Application.Calculation = xlCalculationManual
  • and reset to Manual at the end by Application.Calculation = lngCalc
That is, always Manual
 
Upvote 0
Good point. Another case for why I tend to always use an error handler to reset application settings in case of errors.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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