A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

macro shortcut help



 
 
Thread Tools Display Modes
  #1  
Old March 23rd, 2010, 04:26 PM posted to microsoft.public.excel.worksheet.functions
ericaamousseau
external usenet poster
 
Posts: 17
Default macro shortcut help

Hello I have a Macro set up in spreadsheets I have made for multiple people.
I have set it up so they can paste the info needed in a worksheet and then
use the shortcut ctr(a) to run the macro below to delete all rows with lab in
it.

Sub Find_LAB()
Dim rng As Range
Dim what As String
what = "LAB"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Exit Do
Else
Rows(rng.Row).Delete
End If
Loop
End Sub


This worked well for a while but now I find that the shortcut is not
working. any idea why this is? thanks for any help!
  #2  
Old March 23rd, 2010, 07:01 PM posted to microsoft.public.excel.worksheet.functions
TomPl
external usenet poster
 
Posts: 239
Default macro shortcut help

I couldn't make sense of your code so I wrote this to do what I think you want:

Sub mcrDelete_If_LAB()

Dim rngRow As Range

For Each rngRow In ActiveSheet.UsedRange.Rows
If Not rngRow.Find("LAB") Is Nothing Then
rngRow.Delete
End If
Next rngRow

End Sub

Try It

Tom
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.