IF cells contains text then replace by the lat cell in its corresponding collumn

JODomingos

New Member
Joined
Jul 11, 2020
Messages
48
Office Version
  1. 2016
Platform
  1. Windows
Hi Fellows!

I'm stuck in this script, I can not solve.
The point is: I need to check in many columns if there is the string "./.", in case of having then replace it by the last row in its column (Yellow), which contains the average. I can do it one by one but I need to perform this several times (4723times). I could not develop a loop for that. After finished the replacement for the class A, i have to move to class B e perform the same script.

Could you help me?



excel.JPG



Below follows my script
Sub replace()
Dim C As Range

Dim grupo As Range

Set grupo = Range(ActiveCell, ActiveCell.End(xlDown))

Application.ScreenUpdating = False

For Each C In grupo


If C = "./." Then C = ActiveCell.End(xlDown).Value
Next C

ActiveCell.Offset(0, 1).Select


Application.ScreenUpdating = True

End Sub

Really thanks
 

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

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,975
Office Version
  1. 2016
Platform
  1. Windows
Does this macro do what you want...
VBA Code:
Sub ReplaceDotSlashDotWithAverage()
  Dim Cell As Range
  For Each Cell In Range("C4", Cells(Rows.Count, "J").End(xlUp)).SpecialCells(xlConstants)
    Cell.Replace "./.", Cell.End(xlDown).Value, xlWhole, , , , False, False
  Next
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,562
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
Sub JODomingos()
   Dim Cl As Range, Rng As Range
   Dim Ar As Areas
   
   For Each Rng In Range("A:A").SpecialCells(xlConstants).Areas
      For Each Cl In Rng.CurrentRegion.Columns
         Cl.Replace "./.", Cells(Rng.Offset(Rng.Count - 1).Resize(1).Row, Cl.Column)
      Next Cl
   Next Rng
End Sub
 

JODomingos

New Member
Joined
Jul 11, 2020
Messages
48
Office Version
  1. 2016
Platform
  1. Windows
This is Just Fabulous!! It Worked Perfectly.
Thank you Rick A lot.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,562
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,593
Messages
5,637,294
Members
416,963
Latest member
zazama

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
Top