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 does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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
 
Upvote 0
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
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,840
Messages
6,121,895
Members
449,058
Latest member
Guy Boot

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