Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 193
Default Deleting specific text using VBA ?

I have a spreadsheet that contains over 6,000 lines and 20 columns. The
spreadsheet changes often. Each of these columns may have "0", "-", "0.00%",
"call desk" etc. Instead of manually recording the macros to delete these
specific values for each column, is there a code to do this?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Deleting specific text using VBA ?

Adapt this small macro to your needs:

Sub cleanup()
s = Array("0", "-", "0.00%", "call desk")
For Each r In ActiveSheet.UsedRange
v = r.Text
For i = 0 To 3
If v = s(i) Then
r.Clear
End If
Next
Next
End Sub

--
Gary''s Student - gsnu200774


"Confused" wrote:

I have a spreadsheet that contains over 6,000 lines and 20 columns. The
spreadsheet changes often. Each of these columns may have "0", "-", "0.00%",
"call desk" etc. Instead of manually recording the macros to delete these
specific values for each column, is there a code to do this?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 193
Default Deleting specific text using VBA ?

Thanks. This works great.
What if the "-" is actually a "0" but shows up as a "-"? what is the
correct way to show that in the array?

"Gary''s Student" wrote:

Adapt this small macro to your needs:

Sub cleanup()
s = Array("0", "-", "0.00%", "call desk")
For Each r In ActiveSheet.UsedRange
v = r.Text
For i = 0 To 3
If v = s(i) Then
r.Clear
End If
Next
Next
End Sub

--
Gary''s Student - gsnu200774


"Confused" wrote:

I have a spreadsheet that contains over 6,000 lines and 20 columns. The
spreadsheet changes often. Each of these columns may have "0", "-", "0.00%",
"call desk" etc. Instead of manually recording the macros to delete these
specific values for each column, is there a code to do this?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 193
Default Deleting specific text using VBA ?

For my own educational purposes, can you explain what s, v, r, and i mean?
also, what is the purpose of the line "For i = 0 To 3"?

Thanks.
"Gary''s Student" wrote:

Adapt this small macro to your needs:

Sub cleanup()
s = Array("0", "-", "0.00%", "call desk")
For Each r In ActiveSheet.UsedRange
v = r.Text
For i = 0 To 3
If v = s(i) Then
r.Clear
End If
Next
Next
End Sub

--
Gary''s Student - gsnu200774


"Confused" wrote:

I have a spreadsheet that contains over 6,000 lines and 20 columns. The
spreadsheet changes often. Each of these columns may have "0", "-", "0.00%",
"call desk" etc. Instead of manually recording the macros to delete these
specific values for each column, is there a code to do this?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Deleting specific text using VBA ?

s is an array variable - just a list of values
v is the value of the data in the cell being examined
r is a range variable - it represents the cells being examined
i is a loop variable - we are repeating everything between For and Next 4
times
--
Gary''s Student - gsnu200774


"Confused" wrote:

For my own educational purposes, can you explain what s, v, r, and i mean?
also, what is the purpose of the line "For i = 0 To 3"?

Thanks.
"Gary''s Student" wrote:

Adapt this small macro to your needs:

Sub cleanup()
s = Array("0", "-", "0.00%", "call desk")
For Each r In ActiveSheet.UsedRange
v = r.Text
For i = 0 To 3
If v = s(i) Then
r.Clear
End If
Next
Next
End Sub

--
Gary''s Student - gsnu200774


"Confused" wrote:

I have a spreadsheet that contains over 6,000 lines and 20 columns. The
spreadsheet changes often. Each of these columns may have "0", "-", "0.00%",
"call desk" etc. Instead of manually recording the macros to delete these
specific values for each column, is there a code to do this?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help in deleting specific data. tweacle[_2_] Excel Worksheet Functions 1 August 30th 07 11:28 AM
Deleting a Row if it contains a specific word Steve Madsen Excel Discussion (Misc queries) 1 February 1st 07 09:58 PM
Deleting row with specific value Jed Excel Discussion (Misc queries) 2 January 12th 06 01:59 PM
Deleting specific records [email protected] Excel Discussion (Misc queries) 6 June 22nd 05 11:35 PM
Deleting Specific Rows ScaffoldingDepot Excel Discussion (Misc queries) 2 May 4th 05 04:08 PM


All times are GMT +1. The time now is 08:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"