Error When Pasting Equation from Notepad into Excel Using Recorded Macro

mjd95964

New Member
Joined
Mar 11, 2022
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
I'm encountering an issue while recording a macro in Excel for a repetitive task. During the task, I copy an equation from Notepad and paste it into Excel. However, when I attempt to apply this macro to the next day's sheet, I encounter this error

1.PNG



The second problem is when i do "auto fill" for the equation , let's say this day we have 50 rows and tomorrow there will be 90 rows .. when i apply the macro i found the it only made auto fill for 50 rows ?

How can I resolve this issue?
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
It would be extremely beneficial if you could post your VBA code for us to see!
Please use code tags when posting your code, as noted here: How to Post Your VBA Code

For your auto-fill, the key is to dynamically find the last row of data, and use that variable in your code.

For example, to find the last row with data in column A, you can do this:
VBA Code:
Dim lr as Long
lr = Cells(Rows.Count, "A").End(xlUp).Row

You can then reference the range from A2 to the end of column A like this:
VBA Code:
Range("A2:A" & lr)
 
Upvote 0
It would be extremely beneficial if you could post your VBA code for us to see!
Please use code tags when posting your code, as noted here: How to Post Your VBA Code

For your auto-fill, the key is to dynamically find the last row of data, and use that variable in your code.

For example, to find the last row with data in column A, you can do this:
VBA Code:
Dim lr as Long
lr = Cells(Rows.Count, "A").End(xlUp).Row

You can then reference the range from A2 to the end of column A like this:
VBA Code:
Range("A2:A" & lr)
Thank you for your response
I dont use VBA , i am still a beginner at Excel so I use record macro without entering VBA details, or do you mean i had to enter this code inside VBA ?
 
Upvote 0
In Excel. "macros" and "VBA" are really the same thing.
If you use the Macro Recorder, you are just letting Excel create the VBA, but trust me, what you are creating is actually VBA.

Please post the code the Macro Recorder created that you are using.

Note that while the Macro Recorder is a great tool to get snippets of code, it is quite literal, and often needs cleaning-up/editing in order to make it more dynamic.
So it is a great starting point, but often requires edits.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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