Conditionally converting forumlae to values

darcus

New Member
Joined
Jun 30, 2014
Messages
29
Hi

I hope you can help.

I can't get my head around how to do this.

Column T I enter a date value.
Once I enter a value, formulae in columns S and V calculate a figure.
This all happens on the same row.

I would like to run a command to convert every cell in columns S and V from their formulae to their values provided the cell in the same row in column T has a value entered into it. I am doing this in a large workbook so in effect, it is simply going to remove all formulae that have given a result only.

Is this doable?

Kind regards,
d
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi, maybe you could give this a try:

Code:
Sub M()
Dim C As Range
For Each C In Range("T2:T" & Range("T" & Rows.Count).End(xlUp).Row).Cells
    If Len(C.Value) Then
        Range("S" & C.Row).Value = Range("S" & C.Row).Value
        Range("V" & C.Row).Value = Range("V" & C.Row).Value
    End If
Next C
End Sub
 
Upvote 0
Thank You!!!
Hi, maybe you could give this a try:

Code:
Sub M()
Dim C As Range
For Each C In Range("T2:T" & Range("T" & Rows.Count).End(xlUp).Row).Cells
    If Len(C.Value) Then
        Range("S" & C.Row).Value = Range("S" & C.Row).Value
        Range("V" & C.Row).Value = Range("V" & C.Row).Value
    End If
Next C
End Sub

That worked brilliantly. It is very slow on a 20k+ row sheet. But it did the job.

Just so that I understand the code:
The beginning of the For statement determines when to finish the loop
If Len(C.Value) means that if the cell in C has a value then do whats between the If and the End If.

is that right?

d
 
Last edited:
Upvote 0
is that right?

Hi, nearly, the For Loop line could be described as - work out the last used row column T and use that to define a range from T2 to the last used row in T and then cycle througheach cell within that range:


Rich (BB code):
For Each C In Range("T2:T" & Range("T" & Rows.Count).End(xlUp).Row).Cells
 
Upvote 0
Once I enter a value, formulae in columns S and V calculate a figure.
If by "figure" you mean a number, then this macro might prove to be faster...
Code:
Sub ChangeFormulasDisplayingNumbersToContants()
  Dim Ar As Range
  With Range("S:S,V:V").SpecialCells(xlFormulas, xlNumbers)
    .Value = .Value
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,368
Messages
6,124,523
Members
449,169
Latest member
mm424

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