0

I'm working with macros in 2 different computers, the one I take to the office has this issue where I record a series of steps and by the time I use the Macro it is not working. I tried every single step by its own and the problem seems to be that the .Select step, where I select a cell after a copy process, isn´t been recorded:

THIS IS WHAT SHOULD'VE BEEN RECORDED:

Sub Macro1()
'
' Macro1 Macro
'

'
    Range("D5:D7").Select
    Selection.Copy
    Range("F5").Select
    ActiveSheet.Paste
    Range("H7").Select
    Application.CutCopyMode = False
End Sub

THIS IS WHAT HAS BEEN RECORDED:

Sub Macro1()
'
' Macro1 Macro
'

'
    Range("D5:D7").Select
    Selection.Copy
    ActiveSheet.Paste
    Application.CutCopyMode = False
End Sub

I've tested this on both computers and with the same document and different ones, only happends on the computer I take to work. Then I tryed reinstaling Office, not fixing the problem either. TY for help.

gabo mendi
  • 11
  • 1
  • 4
    Macro created from the recorder is not reliable, you should only use it as a starting point of what you want to do. Read [on how to avoid using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?rq=1). – Raymond Wu Jan 12 '22 at 01:46
  • 1
    That code can be simplified to `Range("D5:D7").Copy Destination:=Range("F5")` – BigBen Jan 12 '22 at 01:59
  • I just need macro recording to work properly, thank you though – gabo mendi Jan 12 '22 at 03:37

2 Answers2

2

If you select a cell but do not do anything else with that cell, the Macro Recorder will not record the step. Nothing is wrong with your recorder.

As other users have pointed out, this is a blessing in disguise as using the .Select method will both lengthen your code blocks, and run time.

TehDrunkSailor
  • 633
  • 4
  • 11
1

Reinstalled Windows, problem is fixed, ty for nothing :P

gabo mendi
  • 11
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 13 '22 at 08:59