Using Macro to Select Rows Containing Certain Text

mmahercpa

New Member
Joined
Dec 29, 2015
Messages
4
Hello all,

I have been trying to create a macro to correct the formulas in certain rows of a spreadsheet where the first cell in the row contains the text "avg," but that is not the only text in the cell. Any ideas?

Ex:
Cell A83 contains "Avg. Accounts Rec. to Earned Revenues"
and Cell A85 contains "Avg. accts. pay. & accrued exp. to revenues".

In the spreadsheet, my macro is designed to insert a new year column and carry forward the prior 9 years of data, but when I insert the new row, it messes up the formulas for the average ratios, which use data from the previous column as well as the current column.

This is the code for the formula I am using.

Range("H83").Select
Selection.AutoFill Destination:=Range("C83:H83"), Type:=xlFillDefault
Selection.AutoFill Destination:=Range("C83:L83"), Type:=xlFillDefault
Selection.AutoFill Destination:=Range("C85:H85"), Type:=xlFillDefault
Selection.AutoFill Destination:=Range("H85:L85"), Type:=xlFillDefault
Selection.AutoFill Destination:=Range("H94:L94"), Type:=xlFillDefault
Selection.AutoFill Destination:=Range("C94:H94"), Type:=xlFillDefault

I want my macro to apply to other spreadsheets, but the average ratios are not necessarily in the above rows, so I want to generalize the macro for those spreadsheets.


I am using Excel 2013 on Windows 7, if that helps anyone.

Thank you in advance for your assistance.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Please use Excel Jeanie (or similar -- see link in my sig) to post a representative portion of your worksheet, including the "formulas for the average ratios, which use data from the previous column as well as the current column."

What are the formulas now?
What should they be changed to?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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