Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel2000 VBA If-Then/Loop Failures

Excel Spreadsheet with fixed number of columns (44) and varying numbe
of rows. The data of interest starts at ROW 9.

After worksheet is updated by Shipping (Column Q), Object of macro i
to hide rows that have shipped.

Look at each ROW in column "Q". Looking for word "Shipped".

If found "Shipped" then stop, select the entire ROW and hide it. The
GOTO next row. Repeat.

IF not found Then go to next row. Repeat.

Continue to end of rows. End

I have tried LOOPS, FOR NEXT, IF THEN and can't seem to find
combination that works! What am I missing??? HELP

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Excel2000 VBA If-Then/Loop Failures

This will do it, but it's just as easy to use Data / Filter / Autofilter. The
code will prompt you for a value, so if you don't want it to do that, use the
second variant:-

Sub HideRows()

ans = InputBox("What string do you want rows to be Hidden if they contain it?")
Application.ScreenUpdating = False

LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

Set Rng = Range(Cells(1, "Q"), Cells(LastRow, "Q"))

With Rng
.AutoFilter
.AutoFilter Field:=1, Criteria1:="<" & ans
End With
Application.ScreenUpdating = True

End Sub

'-------------------------------------------

Sub HideRows()

Application.ScreenUpdating = False

LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count

Set Rng = Range(Cells(1, "Q"), Cells(LastRow, "Q"))

With Rng
.AutoFilter
.AutoFilter Field:=1, Criteria1:="<Shipped"
End With
Application.ScreenUpdating = True

End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"prodsched " wrote in message
...
Excel Spreadsheet with fixed number of columns (44) and varying number
of rows. The data of interest starts at ROW 9.

After worksheet is updated by Shipping (Column Q), Object of macro is
to hide rows that have shipped.

Look at each ROW in column "Q". Looking for word "Shipped".

If found "Shipped" then stop, select the entire ROW and hide it. Then
GOTO next row. Repeat.

IF not found Then go to next row. Repeat.

Continue to end of rows. End

I have tried LOOPS, FOR NEXT, IF THEN and can't seem to find a
combination that works! What am I missing??? HELP!


---
Message posted from http://www.ExcelForum.com/



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.605 / Virus Database: 385 - Release Date: 01/03/2004


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel2000 VBA If-Then/Loop Failures

Thank you so much for your quick response.

I have tried both routines and both cause and error message a
follows.

Runtime Error 438
Object doesn't support this property or method.

I have entered values for LastRow=ActiveSheet.UsedRange.Row-1+_

I have used positive and negative integers and keep getting the erro
message.

Apparently I am still missing something here. Thanks again..

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Excel2000 VBA If-Then/Loop Failures

Hmmm - Works fine for me in 2000. What line does it error on? It didn't suffer
from wordwrap anywhere did it, such that you may see red lines of data in the
code when you pasted it in. Happy to send you a copy that is working on my
machine, and then if that doesn't work will have to think again as to what is
causing it. If you want me to send you that then email me taking the NOSPAM bit
out of my email address



--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"prodsched " wrote in message
...
Thank you so much for your quick response.

I have tried both routines and both cause and error message as
follows.

Runtime Error 438
Object doesn't support this property or method.

I have entered values for LastRow=ActiveSheet.UsedRange.Row-1+_

I have used positive and negative integers and keep getting the error
message.

Apparently I am still missing something here. Thanks again...


---
Message posted from
http://www.ExcelForum.com/



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.608 / Virus Database: 388 - Release Date: 03/03/2004


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel2000 VBA If-Then/Loop Failures

Hello Ken:

Thank you for your patience with me.

I have discovered the problem.

The third line of code reads, "LastRow=Active.Sheet.UsedRange.Row-1+_"

Duh....Where the _ is I had a number there instead! Why, I don't know.

In any case I have replaced the number with _ and all works fine now

Thanks again so very much.

Best regards

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Excel2000 VBA If-Then/Loop Failures

LOL - Good Stuff - That _ simply denotes a continuation onto the next line for
that statement.

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"prodsched " wrote in message
...
Hello Ken:

Thank you for your patience with me.

I have discovered the problem.

The third line of code reads, "LastRow=Active.Sheet.UsedRange.Row-1+_"

Duh....Where the _ is I had a number there instead! Why, I don't know.

In any case I have replaced the number with _ and all works fine now!

Thanks again so very much.

Best regards,


---
Message posted from http://www.ExcelForum.com/



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.608 / Virus Database: 388 - Release Date: 03/03/2004


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
workbook link failures curiouskiwi Links and Linking in Excel 3 October 23rd 08 09:32 AM
Excel 2002 : Need patching for formula failures Mr. Low Excel Discussion (Misc queries) 1 May 20th 08 06:30 PM
Excel2000 Christina Feichter Excel Programming 0 January 26th 04 07:38 PM
Excel2000 Upgrades MWE[_14_] Excel Programming 0 January 24th 04 10:39 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 04:40 PM.

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

About Us

"It's about Microsoft Excel"