Simple Macro Failures

Denny57

Board Regular
Joined
Nov 23, 2015
Messages
185
Office Version
  1. 365
Platform
  1. Windows
Can someone please advise me if there is some form of configuration which might cause even the simplest macro to Fail.

Working through a basic course I am trying to create the most simple of macros,using the "Record Macro" function in the VB editor. I am simply recording a macro that will copy text into any cell in which the Macro is run. However, the process creates an additional line of code referring to the source cell, regardless of which cell I use to record the macro.

VBA Code:
Sub Macro3()
'
' Macro3 Macro

    Range("A1").Select
    ActiveCell.FormulaR1C1 = "Excel VBA"
    Range("A2").Select
End Sub

The text was typed in to Cell A1 and the macro is failing because of the additional first line in the code however, it fails regardless of which cell I use to record the macro.

I need to know if this is a configuration change as otherwise I cannot trust Excel to behave as it should.

Many thanks
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
After you started recording the macro:
-you selected A1
-inserted the formula in the selected cell
-automatically the selection moved to the next cell

What has been recorded is correct
If you want the action (insert formula) be excecuted in whichever cell is the active one then just remove Line 1 and Line 3 from the recorded code
 
Upvote 0
Solution
Thank You.. This is probably down to a habit of selecting cells whenever I want to use them even when it has already the selelcted cell
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

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