Is there a VBA method to modify many columns of data rather than by inserting new columns with formulas?

ExcelLearner25

New Member
Joined
Jan 20, 2023
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
I have a big spreadsheet that needs lots of processing to fix problems introduced from a conversion. I've been using VBA to mimic how I would do it manually: insert blank columns, put a formula in each column to modify the old data, then hide or delete the original column, leaving the new columns with the modified data (I convert it to values too when it's done).

But adding all these columns and formulas with code seems like an inefficient way of doing this. Is there a better way, such as by having VBA that directly modifies the original columns of values?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
It's a lot of formatting problems. For example, the conversion sometimes inserts the word "Effective" into the date column rather than the "Description" column where it belongs. So I have some code that strips "effective" out of the date column, and properly formats the remaining text as a date (deleting line returns, blank spaces), and separate code that adds the word to the proper location in the description. All this includes IF statements to make sure it's only done where necessary.

Elsewhere, a column of dollar values is in text format with negative values using a trailing hyphen. So I fix those too.

There are lots of other little fixes like this. (I don't have time at this minute to learn how to use XL2BB but will this weekend)
 
Upvote 0
There are lots of other little fixes like this. (I don't have time at this minute to learn how to use XL2BB but will this weekend)
I'll try and have a look once you have posted the sample as there isn't anything I can propose without seeing what we are dealing with.
 
Upvote 0
Here's a sample of what I have. The cells with orange are the starting point. The cells in red text are the finished product. I use VBA to insert all the formulas. It's not pretty, and it's difficult to maintain.

Cell Formulas
RangeFormula
D4,L4,I4,G4D4=RegSplit(C4, "[\r\n].",0," (CaseInSensitive)")
E4,M4,J4E4=SUBSTITUTE(C4,D4,)
F4,N4,K4F4=SUBSTITUTE(E4,CHAR(10),"",1)
O4O4=G4 & " " & N4
P4P4=TRIM(L4 & " " & T4 & CHAR(10) & O4)
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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