Newbee - Replace values in a Column

  • Thread starter Thread starter Pete Beatty
  • Start date Start date
P

Pete Beatty

I am working with a sheet that has several columns that contain "True" or
"False" data in the cells. I have been able to change all "True" to "Yes"
and "False" to space, wherever they exist in the sheet. I now want to
change any "Yes" values, within a column to a space. The column is "G" and
has "CardReq" in the first cell position.

I use the following code to make the current changes and would like to add
the new code to this routine. Can anyone assist??

' setup the filename and open it...
Set mySheet = xlApp.WorkBooks.Open(xlsFile).Sheets(1)
TotalRows = mySheet.UsedRange.Rows.Count
TotalColumns = mySheet.UsedRange.Columns.Count

' Replace all "TRUE" cells with "Yes"
mySheet.Cells.Replace What:="True", _
Replacement:="Yes", _
LookAt:=xlPart, _
MatchCase:=False

' Replace all "FALSE: cells with a single space
mySheet.Cells.Replace What:="False", _
Replacement:=Space$(1), _
LookAt:=xlPart, _
MatchCase:=False

' Save the worksheet and close the application
mySheet.Application.ActiveWorkbook.Save
mySheet.Application.ActiveWorkbook.Close
xlApp.Quit
 
Pete

Take the code lines from here

Sub replaceYes()
Columns("G:G").Replace What:="Yes", _
Replacement:=Space$(1)
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
(e-mail address removed)
 
Thanks.

Nick Hodge said:
Pete

Take the code lines from here

Sub replaceYes()
Columns("G:G").Replace What:="Yes", _
Replacement:=Space$(1)
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top