Removing Ranges where a column has X value

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a worksheet with hundreds of rows and at irregular intervals Column B has the string "Prod1" in it.

Columns C-L of each of these rows with Prod1 all have formulas in them which is dynamic, This for example is the formulas in cell C8 =IF($Y$1="Yes",C7,IF(C4>C7,0,C7-C4)) .

I want to be able to manually type over the formulas at times as it is a necessity. Once I have completed a weekly run of putting in the manual entries I then want to put all of the formulas in the Prod 1 rows columns C-L back in.

What I have come here for help with is if I put the formula above in a random cell lets say Z8 can i then run a piece of code that puts this formulas back into Columns C to L for all rows with Prod 1 in Column B?

Sorry if I have not explained this very well I am able to provide further input if needed, thanks in advance
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
*apologies I have said removing I meant to say replacing ranges
 
Upvote 0
I have worked this out thanks
Sub RestoreFormulas()
Dim lastRow As Long
Dim ws As Worksheet
Dim cell As Range

' Set the worksheet where your data is located
Set ws = ThisWorkbook.Sheets("Sheet1")


lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row


For Each cell In ws.Range("B1:B" & lastRow)
If cell.Value = "Prod1" Then

ws.Range("Z8").Copy Destination:=ws.Range("C" & cell.Row & ":L" & cell.Row)
End If
Next cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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