Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combining find with clearcontents on multiple columns




Sub clearZLRPIN()
'
' clearZLRPIN Macro
' Macro recorded 4/17/2003 by R Todd
'
Hi,

I am working on a macro that is close but not quite there. At various
points throughout the sheet, starting a row 1, column K contains
"ZLRPI". I'd like the macro to find all occurences in the spreadsheet
and each time clear columns K:M.

My code appears to stop after each occurence, and the occurrence at row
1 is the last to be cleared.

Can anyone offer constructive suggestions?

Thanks,
RussB

Sub ClearProgram
On Error GoTo Jump_Out

Range("A1").Select
Columns("K:K").Select
Selection.Find(What:="ZLRPI", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext _
, MatchCase:=True).Activate
Range(ActiveCell, ActiveCell.Offset(0, 2)).Select
Selection.ClearContents
ActiveCell.Select
Do
Selection.FindNext(After:=ActiveCell).Activate
Range(ActiveCell, ActiveCell.Offset(0, 2)).Select
Selection.ClearContents
Loop Until False
Jump_Out:
Range("A1").Select
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Combining find with clearcontents on multiple columns

Something like:

Sub ClearZLRPI()
Dim c As Range
For Each c In Range("K4:K25")
If c.Value = "ZLRPI" Then c.Resize(1, 3).ClearContents
Next c
End Sub

"RussB" wrote in message
ups.com...



Sub clearZLRPIN()
'
' clearZLRPIN Macro
' Macro recorded 4/17/2003 by R Todd
'
Hi,

I am working on a macro that is close but not quite there. At various
points throughout the sheet, starting a row 1, column K contains
"ZLRPI". I'd like the macro to find all occurences in the spreadsheet
and each time clear columns K:M.

My code appears to stop after each occurence, and the occurrence at row
1 is the last to be cleared.

Can anyone offer constructive suggestions?

Thanks,
RussB

Sub ClearProgram
On Error GoTo Jump_Out

Range("A1").Select
Columns("K:K").Select
Selection.Find(What:="ZLRPI", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext _
, MatchCase:=True).Activate
Range(ActiveCell, ActiveCell.Offset(0, 2)).Select
Selection.ClearContents
ActiveCell.Select
Do
Selection.FindNext(After:=ActiveCell).Activate
Range(ActiveCell, ActiveCell.Offset(0, 2)).Select
Selection.ClearContents
Loop Until False
Jump_Out:
Range("A1").Select
End Sub



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
combining multiple columns from multiple files osiris73 Excel Discussion (Misc queries) 2 January 17th 07 03:30 AM
Help combining multiple columns into one [email protected] Excel Discussion (Misc queries) 8 December 28th 06 09:49 PM
Combining Multiple Columns into One J.J. Excel Worksheet Functions 3 March 21st 06 03:25 PM
Combining multiple columns of text Amber Schellenberg Excel Discussion (Misc queries) 2 October 11th 05 11:45 PM
Combining text from multiple columns into 1 stelee Excel Discussion (Misc queries) 3 July 6th 05 11:04 AM


All times are GMT +1. The time now is 03:19 AM.

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"