View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Help with Selection.Replace

Should have included this before.

Please don't take offence to my suggesting this but ensure you have the code
in the correct worksheet module. (Right click on the worksheet tab name and
select view code and ensure it is there.)

--
Regards,

OssieMac


"Ayo" wrote:

When I run this click macro from inside a worksheet, nothing happens. The
changes I am trying to make are not done but the code works fine when I run
it manually.
Any ideas what is going wrong?

Private Sub cmdMarketRegion_Click()
If Me.cmdMarketRegion.Caption = "Market" Then
Me.cmdMarketRegion.Caption = "Region"
Me.Range("D7,D23,D39") = "Market"
Me.Cells.Select
With Selection
.Replace What:="=$D$7", Replacement:="<"""
End With
Me.Range("A2").Select
ElseIf Me.cmdMarketRegion.Caption = "Region" Then
Me.cmdMarketRegion.Caption = "Market"
Me.Range("D7,D23,D39") = "Region"
Me.Cells.Select
With Selection
.Replace What:="--('InSite Milestones'!$A$2:$A$9245=$E$4)",
Replacement:="--('InSite
Milestones'!$A$2:$A$9245<"")"
End With
Me.Range("A2").Select
End If

Me.Calculate
End Sub