ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete (https://www.excelbanter.com/excel-discussion-misc-queries/223596-delete.html)

chrisnsmith

Delete
 
Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm

Dave Peterson

Delete
 
With activesheet
With .range("c6:c" & .rows.count)
.cells.replace ....
end with
end with

Did you really mean xlpart, not xlwhole?

chrisnsmith wrote:

Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm


--

Dave Peterson

Sheeloo[_3_]

Delete
 
You need to first select the range then run the macro below;
Change from your macro = replaces Cells (which means all cells on the
worksheet with Selection)

If you do not want to select the range before running the macro then remove
the ' before the line
' Range("F6:F50").Select
and change 50 to whatever you want...

Use
Sub Macro1()
' Range("F6:F50").Select
Selection.Replace What:="O", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

"chrisnsmith" wrote:

Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm


chrisnsmith

Delete
 
That works if there are O's in column C, but I should have asked for
something that will function just as well when there are no O's in column C.
Can you help?

"Sheeloo" wrote:
You need to first select the range then run the macro below;
Change from your macro = replaces Cells (which means all cells on the
worksheet with Selection)

If you do not want to select the range before running the macro then remove
the ' before the line
' Range("F6:F50").Select
and change 50 to whatever you want...

Use
Sub Macro1()
' Range("F6:F50").Select
Selection.Replace What:="O", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

"chrisnsmith" wrote:

Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm


Dave Peterson

Delete
 
Wouldn't a minor test tell you the answer faster than waiting for an answer?

chrisnsmith wrote:

That works if there are O's in column C, but I should have asked for
something that will function just as well when there are no O's in column C.
Can you help?

"Sheeloo" wrote:
You need to first select the range then run the macro below;
Change from your macro = replaces Cells (which means all cells on the
worksheet with Selection)

If you do not want to select the range before running the macro then remove
the ' before the line
' Range("F6:F50").Select
and change 50 to whatever you want...

Use
Sub Macro1()
' Range("F6:F50").Select
Selection.Replace What:="O", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

"chrisnsmith" wrote:

Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm


--

Dave Peterson

chrisnsmith

Delete
 
I'm not sure I understand what you mean. I did test the codes that both you
and Sheloo posted. I tried eliminating lines that I thought might be causing
a problem when there were no O's in column C, but I'm a novice at this and am
not sure what lines I should be eliminating. All I know is that when I try
to run the code, and there are no O's to replace I get a highlight in the VB
module.

"Dave Peterson" wrote:

Wouldn't a minor test tell you the answer faster than waiting for an answer?

chrisnsmith wrote:

That works if there are O's in column C, but I should have asked for
something that will function just as well when there are no O's in column C.
Can you help?

"Sheeloo" wrote:
You need to first select the range then run the macro below;
Change from your macro = replaces Cells (which means all cells on the
worksheet with Selection)

If you do not want to select the range before running the macro then remove
the ' before the line
' Range("F6:F50").Select
and change 50 to whatever you want...

Use
Sub Macro1()
' Range("F6:F50").Select
Selection.Replace What:="O", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

"chrisnsmith" wrote:

Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm


--

Dave Peterson


chrisnsmith

Delete
 
Forget it. Used the replace command instead.

"Dave Peterson" wrote:

With activesheet
With .range("c6:c" & .rows.count)
.cells.replace ....
end with
end with

Did you really mean xlpart, not xlwhole?

chrisnsmith wrote:

Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm


--

Dave Peterson


Dave Peterson

Delete
 
Share the snippet of code and indicate the line that causes the error.


chrisnsmith wrote:

I'm not sure I understand what you mean. I did test the codes that both you
and Sheloo posted. I tried eliminating lines that I thought might be causing
a problem when there were no O's in column C, but I'm a novice at this and am
not sure what lines I should be eliminating. All I know is that when I try
to run the code, and there are no O's to replace I get a highlight in the VB
module.

"Dave Peterson" wrote:

Wouldn't a minor test tell you the answer faster than waiting for an answer?

chrisnsmith wrote:

That works if there are O's in column C, but I should have asked for
something that will function just as well when there are no O's in column C.
Can you help?

"Sheeloo" wrote:
You need to first select the range then run the macro below;
Change from your macro = replaces Cells (which means all cells on the
worksheet with Selection)

If you do not want to select the range before running the macro then remove
the ' before the line
' Range("F6:F50").Select
and change 50 to whatever you want...

Use
Sub Macro1()
' Range("F6:F50").Select
Selection.Replace What:="O", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

"chrisnsmith" wrote:

Recorded this macro, but I only want it to work in column C from row 6
downward.
What do I need to add?

Cells.Replace What:="O", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceForm


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 07:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com