VBA code to be copy and pasted from cells

Jonnny

New Member
Joined
Dec 19, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have a VBA code in cells B2:D5 which automatically updated according to table. And I copy and paste the code to update the macro.
Can VBA somehow take the code from cells and paste?
is there a such function?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I can see that your using the terms "VBA code" and "macro", but the question doesn't make sense to me.

Are you asking:
"I have formulas in cells B2:D5 which automatically update according to table. I copy and paste those cells to a different part of the worksheet. Can VBA somehow take the cells and paste them elsewhere automatically?"

Yes, A VBA macro can copy and paste cells elsewhere automatically
 
Upvote 0
For instance, in cells B2:B33 I have VBA code as below.
1709038195581.png


I made a formula to update the row and column number according to my requirement. But I need to copy and paste to update the VBA code.
My question is, can VBA macro update the code by itself by copy and pasting from B2:B33?
 
Upvote 0
Here is a different thought. Instead of doing something like this, why not already have your base code already in the VB Editor, while you have a control file of values/inputs that the code references/use (via parameters or variables?
 
Upvote 0
No, VBA cannot copy code into the VBA editor. It is strange to see someone creating or editing code in a worksheet. As Joe said, all of your reference material is in VBA.
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

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