PC Review


Reply
Thread Tools Rate Thread

I am pulling my hair out

 
 
James8309
Guest
Posts: n/a
 
      15th Jul 2008
Hi Everyone

I have this code that filters 'non-empty cells' in 4 different sheets
from A3 to last row then paste into sheet5. I think majority of code
is doing what it is suppose to be doing except last one inside of my
For ~ Next statement.

As you can see Sheet1,2,3 and 4 gets filtered and results gets pasted
into sheet5. It is suppose to paste the result then find the lastrow +
1 then paste and so on but It seems it is not doing that.

Can anyone help?

Thank you!

Regards

James


Here is the part of the code

Application.ScreenUpdating = False
LastRange = Sheets("Sheet5").Range("A65000").End(xlUp).Row + 1


shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
With Sheets("Sheet5")
Set CopyToRange = .Range("A" & LastRange)
End With

For sh = 0 To UBound(shArray)
Sheets(shArray(sh)).Activate
LRR = Range("A3").End(xlDown).Row
Set FilterRange = Range("A3", Cells(LRR, "C"))
FilterRange.AutoFilter field:=2, Criteria1:="<>"
FilterRange.Copy Destination:=CopyToRange
FilterRange.AutoFilter
' Problem seems to start
here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
With Sheets("Sheet5")
Set CopyToRange = .Range("A3").End(xlDown)
End With
Next
Application.ScreenUpdating = True
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      15th Jul 2008
Not tested, but maybe

Application.ScreenUpdating = False

shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")

For sh = 0 To UBound(shArray)

With Sheets("Sheet5")

LastRange = .Cells(.Rows.Count, "A6").End(xlUp).Row + 1
Set CopyToRange = .Range("A" & LastRange)
End With

With shArray(sh)

LRR = .Range("A3").End(xlDown).Row
Set FilterRange = .Range("A3", .Cells(LRR, "C"))
FilterRange.AutoFilter field:=2, Criteria1:="<>"
FilterRange.SpecialCells(xlCellTypeVisible).Copy
Destination:=CopyToRange
FilterRange.AutoFilter
End With
Next

Application.ScreenUpdating = True


--
__________________________________
HTH

Bob

"James8309" <(E-Mail Removed)> wrote in message
news:94e4f927-934f-42d4-ad58-(E-Mail Removed)...
> Hi Everyone
>
> I have this code that filters 'non-empty cells' in 4 different sheets
> from A3 to last row then paste into sheet5. I think majority of code
> is doing what it is suppose to be doing except last one inside of my
> For ~ Next statement.
>
> As you can see Sheet1,2,3 and 4 gets filtered and results gets pasted
> into sheet5. It is suppose to paste the result then find the lastrow +
> 1 then paste and so on but It seems it is not doing that.
>
> Can anyone help?
>
> Thank you!
>
> Regards
>
> James
>
>
> Here is the part of the code
>
> Application.ScreenUpdating = False
> LastRange = Sheets("Sheet5").Range("A65000").End(xlUp).Row + 1
>
>
> shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
> With Sheets("Sheet5")
> Set CopyToRange = .Range("A" & LastRange)
> End With
>
> For sh = 0 To UBound(shArray)
> Sheets(shArray(sh)).Activate
> LRR = Range("A3").End(xlDown).Row
> Set FilterRange = Range("A3", Cells(LRR, "C"))
> FilterRange.AutoFilter field:=2, Criteria1:="<>"
> FilterRange.Copy Destination:=CopyToRange
> FilterRange.AutoFilter
> ' Problem seems to start
> here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> With Sheets("Sheet5")
> Set CopyToRange = .Range("A3").End(xlDown)
> End With
> Next
> Application.ScreenUpdating = True



 
Reply With Quote
 
James8309
Guest
Posts: n/a
 
      16th Jul 2008
On Jul 15, 5:59*pm, "Bob Phillips" <Bob...@somewhere.com> wrote:
> Not tested, but maybe
>
> * * Application.ScreenUpdating = False
>
> * * shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
>
> * * For sh = 0 To UBound(shArray)
>
> * * * * With Sheets("Sheet5")
>
> * * * * * * LastRange = .Cells(.Rows.Count, "A6").End(xlUp)..Row + 1
> * * * * * * Set CopyToRange = .Range("A" & LastRange)
> * * * * End With
>
> * * * * With shArray(sh)
>
> * * * * * * LRR = .Range("A3").End(xlDown).Row
> * * * * * * Set FilterRange = .Range("A3", .Cells(LRR, "C"))
> * * * * * * FilterRange.AutoFilter field:=2, Criteria1:="<>"
> * * * * * * FilterRange.SpecialCells(xlCellTypeVisible).Copy
> Destination:=CopyToRange
> * * * * * * FilterRange.AutoFilter
> * * * * End With
> * * Next
>
> * * Application.ScreenUpdating = True
>
> --
> __________________________________
> HTH
>
> Bob
>
> "James8309" <jaedong1...@gmail.com> wrote in message
>
> news:94e4f927-934f-42d4-ad58-(E-Mail Removed)...
>
>
>
> > Hi Everyone

>
> > I have this code that filters 'non-empty cells' in 4 different sheets
> > from A3 to last row then paste into sheet5. I think majority of code
> > is doing what it is suppose to be doing except last one inside of my
> > For ~ Next statement.

>
> > As you can see Sheet1,2,3 and 4 gets filtered and results gets pasted
> > into sheet5. It is suppose to paste the result then find the lastrow +
> > 1 then paste and so on but It seems it is not doing that.

>
> > Can anyone help?

>
> > Thank you!

>
> > Regards

>
> > James

>
> > Here is the part of the code

>
> > Application.ScreenUpdating = False
> > LastRange = Sheets("Sheet5").Range("A65000").End(xlUp).Row + 1

>
> > shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
> > * *With Sheets("Sheet5")
> > * * * *Set CopyToRange = .Range("A" & LastRange)
> > * * * * * *End With

>
> > For sh = 0 To UBound(shArray)
> > * *Sheets(shArray(sh)).Activate
> > * * * *LRR = Range("A3").End(xlDown).Row
> > * * * * * * *Set FilterRange = Range("A3", Cells(LRR, "C"))
> > * * * * * * * *FilterRange.AutoFilter field:=2, Criteria1:="<>"
> > * * * * * *FilterRange.Copy Destination:=CopyToRange
> > * * * *FilterRange.AutoFilter
> > *' Problem seems to start
> > here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> > * *With Sheets("Sheet5")
> > * * * * * * Set CopyToRange = .Range("A3").End(xlDown)
> > * * * * * * * *End With
> > Next
> > Application.ScreenUpdating = True- Hide quoted text -

>
> - Show quoted text -


I am getting object defined error everywhere (T_T)
 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      16th Jul 2008
Everywhere? For example?

--
__________________________________
HTH

Bob

"James8309" <(E-Mail Removed)> wrote in message
news:0e68b89b-43d2-4a16-a64a-(E-Mail Removed)...
On Jul 15, 5:59 pm, "Bob Phillips" <Bob...@somewhere.com> wrote:
> Not tested, but maybe
>
> Application.ScreenUpdating = False
>
> shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
>
> For sh = 0 To UBound(shArray)
>
> With Sheets("Sheet5")
>
> LastRange = .Cells(.Rows.Count, "A6").End(xlUp).Row + 1
> Set CopyToRange = .Range("A" & LastRange)
> End With
>
> With shArray(sh)
>
> LRR = .Range("A3").End(xlDown).Row
> Set FilterRange = .Range("A3", .Cells(LRR, "C"))
> FilterRange.AutoFilter field:=2, Criteria1:="<>"
> FilterRange.SpecialCells(xlCellTypeVisible).Copy
> Destination:=CopyToRange
> FilterRange.AutoFilter
> End With
> Next
>
> Application.ScreenUpdating = True
>
> --
> __________________________________
> HTH
>
> Bob
>
> "James8309" <jaedong1...@gmail.com> wrote in message
>
> news:94e4f927-934f-42d4-ad58-(E-Mail Removed)...
>
>
>
> > Hi Everyone

>
> > I have this code that filters 'non-empty cells' in 4 different sheets
> > from A3 to last row then paste into sheet5. I think majority of code
> > is doing what it is suppose to be doing except last one inside of my
> > For ~ Next statement.

>
> > As you can see Sheet1,2,3 and 4 gets filtered and results gets pasted
> > into sheet5. It is suppose to paste the result then find the lastrow +
> > 1 then paste and so on but It seems it is not doing that.

>
> > Can anyone help?

>
> > Thank you!

>
> > Regards

>
> > James

>
> > Here is the part of the code

>
> > Application.ScreenUpdating = False
> > LastRange = Sheets("Sheet5").Range("A65000").End(xlUp).Row + 1

>
> > shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
> > With Sheets("Sheet5")
> > Set CopyToRange = .Range("A" & LastRange)
> > End With

>
> > For sh = 0 To UBound(shArray)
> > Sheets(shArray(sh)).Activate
> > LRR = Range("A3").End(xlDown).Row
> > Set FilterRange = Range("A3", Cells(LRR, "C"))
> > FilterRange.AutoFilter field:=2, Criteria1:="<>"
> > FilterRange.Copy Destination:=CopyToRange
> > FilterRange.AutoFilter
> > ' Problem seems to start
> > here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> > With Sheets("Sheet5")
> > Set CopyToRange = .Range("A3").End(xlDown)
> > End With
> > Next
> > Application.ScreenUpdating = True- Hide quoted text -

>
> - Show quoted text -


I am getting object defined error everywhere (T_T)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Something that has me pulling my hair out! Randy Kehrt Windows Vista Security 1 17th Dec 2007 08:46 AM
Re: Pulling my hair out lalexander Windows XP Beta Help and Support 2 25th Oct 2004 10:47 AM
Re: Pulling my hair out lalexander Windows XP Configuration 2 25th Oct 2004 10:47 AM
Pulling my hair out lalexander Windows XP Beta 3 25th Oct 2004 10:47 AM
AM PULLING MY HAIR OUT PLEASE HELP ME Windows XP Basics 0 6th Feb 2004 07:56 AM


Features
 

Advertising
 

Newsgroups
 


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