Recorded Macro doing more than what was recorded

bartoax

New Member
Joined
Mar 7, 2018
Messages
5
I have a macro that I recorded to copy columns E-H, and paste values, then delete columns L-R.

The problem that I am having is when I run the macro, instead of pasting values on just E-H, it pastes the values for A-K. I have formulas in some of the other columns that I need to stay as formulas.

Any suggestions on how to fix?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You said:
copy columns E-H, and paste values

Are you saying you want to copy all values in column E-H and paste them back in same column E-H but as values not as formula result?

If not where do you want to paste them?
 
Upvote 0
Welcome to the Board!

Please post the code you have recorded so we can see it.
 
Last edited:
Upvote 0
Here is the code:

Sub QUOTE()
'
' QUOTE Macro
'
' Keyboard Shortcut: Ctrl+q
'
Columns("E:H").Select
Range("E2").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("L:R").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("C1").Select
ActiveWindow.View = xlPageLayoutView
End Sub
 
Upvote 0
Try this simplification:
Code:
Sub QUOTE()
'
' QUOTE Macro
'
' Keyboard Shortcut: Ctrl+q
'
With Columns("E:H")
    .Value = .Value
End With

Columns("L:R").Delete Shift:=xlToLeft

End Sub
 
Upvote 0
Yes, I am posting them back into E-H just as values not formulas.

I use this sheet as a quote, so columns L-R hold all my private cost etc. Columns E-H are pricing formula calculated from the cells in L-R, so I want to turn those into values before deleting L-R. However I have some formulas that I want to remain in my quote to my customer.
Example: Column E is the per each price, Column J is the extended price so it takes column A (the quantity) and multiplies is by the cost. I want this formula to remain so if the customer adjusted their quantities the pricing will update automatically for them. However, when I run the macro (posted in another reply) is turns A-J into values.
 
Upvote 0
I am guessing that you might have missed my last post as you were posting your reply.
I think that code should do what you want.
 
Upvote 0
That is working, but it is taking the macro a long time to run. Is there anything else I can do to speed that up?
 
Upvote 0
I am guessing that you have a lot of data then.

Try this variation:
Code:
Sub QUOTE()
'
' QUOTE Macro
'
' Keyboard Shortcut: Ctrl+q
'
    Dim lRow As Long
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
'   Find last row
    lRow = Range("E1").SpecialCells(xlLastCell).Row
    
    With Range("E1:H" & lRow)
        .Value = .Value
    End With

    Columns("L:R").Delete Shift:=xlToLeft
    
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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