Easy way to convert formula into vba/macro?

Akira181

Board Regular
Joined
Mar 23, 2010
Messages
67
Office Version
  1. 365
Platform
  1. Windows
I have a table of 52 columns 45 rows with a rather long formula in there to build the data. I'm having an issue where sometimes the data will need to be manually entered, which will delete the formula, which I don't want.

Is there an easy way to convert the formula for the whole table into VBA/Macro?

I tried recording a macro > highlighting the table > F2 > enter but it only worked for one cell. The formula is essentially identical throughout apart from the cell references.
 
got another question, hopefully simple for you. Can the clear row part of the code be modified to only clear the cells that are greater (or smaller) than a Calendar Week displayed in Sheet1, G3?

VBA Code:
  .Range(.Cells(rowno - 3, 6), .Cells(rowno - 3, 57)) = ""   ' Clear entire row of week entries
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
change that line of code to this:
VBA Code:
   strcol = Range("G3")
   If strcol < 1 Or strcol = "" Then  ' a bit of error checking
    strcol = 1
   End If
  .Range(.Cells(rowno - 3, 5 + strcol), .Cells(rowno - 3, 57)) = "" ' Clear entire row of week entries
This does greater, I am not sure what you meant by greater or smaller, but you can use a similar type of limit on the "57" if necessary
 
Upvote 0
That works perfectly, thanks again! Not sure why I'm finding VBA so difficult. I understand what you've done thanks to the comments but coming up with the solution myself is a whole different matter.

I got a second VBA problem for a SUMIF / SUMIFS that I posted here (VBA code for SUMIFS function). It's the last half of this file I'm struggling to build.

It should be an easier problem than this one, if you have spare time to take a look, I'll be eternally grateful !
 
Upvote 0

Forum statistics

Threads
1,216,526
Messages
6,131,187
Members
449,631
Latest member
mehboobahmad

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