Macro to replace ? with the actual row number

Chmeee

New Member
Joined
Feb 14, 2005
Messages
3
Hi, I am hoping someone can help me with this
Each week I use a macro to open a Sales spreadsheet that was exported from MSaccess and copy it to my report
However, the freight formula in each row of the spreadsheet is incorrect as it does not show the row numbers
The formula shows as =ROUND(k?*0.01560, 2). Where the “?” should be the row number. Column K contains the various Qtys and the .01560 is the cents per litre.
Is there any way to have the macro change this to the relevant row numbers without having to go down the column selecting each row?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Assuming the formulas are in the Range ("A2:A20") maybe something like

Try it on a copy of your workbook

Code:
Dim rCell As Range

For Each rCell In Range("A2:A20")
    rCell.Formula = Replace(rCell.Formula, "K?", "K" & rCell.Row, compare:=vbTextCompare)
Next rCell

M.
 
Upvote 0
Thanks Marcelo, Works perfectly
It was that quick it was finished before I looked back up from my watch
Will save me lots of time
Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,425
Members
448,961
Latest member
nzskater

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