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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,891
Office Version
  1. 2019
  2. 2010
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
73,402
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
73,402
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,489
Messages
5,837,657
Members
430,507
Latest member
TonyIbbs

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