Gotta activate the sheet before you select the range.
With wb1 With .Sheets(Nome) .Paste .Activate .Range("A1").Select End With End With
Gotta activate the sheet before you select the range.
With wb1 With .Sheets(Nome) .Paste .Activate .Range("A1").Select End With End With
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Gee, what a goofed .
Now that code is working great, but when the code comes to this line:
wb2.Close savechanges:=False
the system simply hangs. I just need to close the wb2. What I am doing wrong now?
Best Regards,
Carlos Paleo.
To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.
If Debugging is harder than writing a program and your code is as good as you can possibly make
it, then by definition you're not smart enough to debug it.
http://www.mugrs.org
Not sure, but I always just leech off the native syntax ..
Does it make a difference?wb2.Close False
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
Okay, that's strange... I don't see anything wrong with that line...
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Well this is my whole logic if it helps:
Dim wb1 As Workbook, wb2 As Workbook Set wb1 = ActiveWorkbook Workbooks.Open Filename:=Arq Set wb2 = ActiveWorkbook With wb2 With .Sheets("CN") .AutoFilterMode = False .Range("D2").Select .Cells.RemoveSubtotal .Cells.Copy End With End With With wb1 With .Sheets(Nome) .Paste .Activate ' Seleciona a c?lula A1 .Range("A1").Select End With End With wb2.Close savechanges:=False ' System hangs here Range("A1").Select ActiveSheet.Select Sheets(Nome).Name = "Standard"
Testing Zacks advice.
Sorry Zack, hanged the same way.
Best Regards,
Carlos Paleo.
To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.
If Debugging is harder than writing a program and your code is as good as you can possibly make
it, then by definition you're not smart enough to debug it.
http://www.mugrs.org
I'm wondering if we can't boil that code down to something like this ...
Dim wb1 As Workbook, wb2 As Workbook Set wb1 = ActiveWorkbook Set wb2 = Workbooks.Open(Arq) With wb2.Sheets("CN") .AutoFilterMode = False .Range("D2").Select .Cells.RemoveSubtotal .Cells.Copy wb1.Sheets(Nome).Range("A1") End With wb2.Close False Range("A1").Select Sheets(Nome).Name = "Standard"
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
And do you even need the line:
It doesn't seem to serve much purpose to me..Range("D2").Select
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Hi guys,
Zack: Great, thanks for the Sub diet. It worked great till the end. No more problems.
Ken: You right, I have removed it.
I am marking it solved now, thank you very much Ken and Zack!
Best Regards,
Carlos Paleo.
To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.
If Debugging is harder than writing a program and your code is as good as you can possibly make
it, then by definition you're not smart enough to debug it.
http://www.mugrs.org
Carlos, does that mean it doesn't hang anymore?Originally Posted by Paleo
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
Yes, exactly. Worked just fine. No more hanging.
Best Regards,
Carlos Paleo.
To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.
If Debugging is harder than writing a program and your code is as good as you can possibly make
it, then by definition you're not smart enough to debug it.
http://www.mugrs.org
Ah, excellent!
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Which all goes to prove three points:
1) Using option explicit removes one potential source for errors
2) Declaring your variables properly removes another potential source for errors
3) Removing all unnecessary code and cutting it down to the bare essentials then removes all other potential sources of errors (and makes it MUCH easier to read the underlying logic)
Good work you guys!
You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you
The major part of getting the right answer lies in asking the right question...
Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.
Glad it works for you Carlos!
John: Thanks buddy!!
Ken: Always a pleasure working with ya!
Regards, Zack Barresse
Check out the KB! :|: BOARD TAGS: WHAT ARE THEY AND HOW DO I USE THEM
What is a Microsoft MVP? | Free Microsoft Courses | My Book on Excel Tables
John, agreed! Nice recap!
It's been a fun one!
Ken Puls, CMA - Microsoft MVP (Excel)
I hate it when my computer does what I tell it to, and not what I want it to.
Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar
This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!
Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!
Many thanks to you all guys!! I was stuck what that and now its solved!! Thanks!!!
Best Regards,
Carlos Paleo.
To every problem there is a solution, even if I dont know it, so this posting is provided "AS IS" with no warranties.
If Debugging is harder than writing a program and your code is as good as you can possibly make
it, then by definition you're not smart enough to debug it.
http://www.mugrs.org