PC Review


Reply
Thread Tools Rate Thread

Called procedure ignoring "With Sheets" command

 
 
Bishop
Guest
Posts: n/a
 
      10th Apr 2009
I have a workbook with two worksheets: Tally Sheet and Catalyst.
I have 2 procedures in this workbook: TallySheetRep and BanSum.
BanSum take a list of data and deletes all the duplicates.
TallySheetRep takes the same data (after BanSum runs), formats it, and
places in my Tally Sheet worksheet.
I call BanSum from TallySheetRep. Here's the problem. If I run
TallySheetRep while in the Catalyst worksheet everything runs fine. But if I
run TallySheetRep while I'm in the Tally Sheet worksheet the code starts
deleting all the duplicate lines in the Tally Sheet worksheet. Here's the
basic layout of my two procedures:

Sub TallySheetRep()
Call BanSum
With Sheets("Catalyst")
...sort, edit, etc.
copy data to sheet Tally Sheet
With Sheets("Tally Sheet")
...populate some formulas
End Sub

Sub BanSum()
With Sheets("Catalyst")
...sort, delete dups, etc.
End Sub

It's like BanSum totally disregards 'With Sheets("Catalyst")' and runs the
code right on the Tally Sheet worksheet instead. Even if I'm on the Tally
Sheet worksheet shouldn't the BanSum code 'go to' the Catalyst worksheet when
it's called? Why is this happening?
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      10th Apr 2009
As you don't post your entire code this is only a guess.

You may miss leading dots which shall set the reference to Catalyst sheet
using the With statement.

With Sheets("Catalyst")
.Range("A1").ClearContents 'Clear A1 on sheet "Catalyst"
Range("A1").ClearContents 'Clear A1 on active sheet

Hopes this helps.

---
Per

"Bishop" <(E-Mail Removed)> skrev i meddelelsen
news:B150ED0F-FAC5-41B9-A2A3-(E-Mail Removed)...
>I have a workbook with two worksheets: Tally Sheet and Catalyst.
> I have 2 procedures in this workbook: TallySheetRep and BanSum.
> BanSum take a list of data and deletes all the duplicates.
> TallySheetRep takes the same data (after BanSum runs), formats it, and
> places in my Tally Sheet worksheet.
> I call BanSum from TallySheetRep. Here's the problem. If I run
> TallySheetRep while in the Catalyst worksheet everything runs fine. But
> if I
> run TallySheetRep while I'm in the Tally Sheet worksheet the code starts
> deleting all the duplicate lines in the Tally Sheet worksheet. Here's the
> basic layout of my two procedures:
>
> Sub TallySheetRep()
> Call BanSum
> With Sheets("Catalyst")
> ...sort, edit, etc.
> copy data to sheet Tally Sheet
> With Sheets("Tally Sheet")
> ...populate some formulas
> End Sub
>
> Sub BanSum()
> With Sheets("Catalyst")
> ...sort, delete dups, etc.
> End Sub
>
> It's like BanSum totally disregards 'With Sheets("Catalyst")' and runs the
> code right on the Tally Sheet worksheet instead. Even if I'm on the Tally
> Sheet worksheet shouldn't the BanSum code 'go to' the Catalyst worksheet
> when
> it's called? Why is this happening?


 
Reply With Quote
 
Bishop
Guest
Posts: n/a
 
      10th Apr 2009
That was EXACTLY the problem. I had a few Cells(#,#) references in the
BanSum code and I didn't put a . in front of them. Thanks!!!

"Per Jessen" wrote:

> As you don't post your entire code this is only a guess.
>
> You may miss leading dots which shall set the reference to Catalyst sheet
> using the With statement.
>
> With Sheets("Catalyst")
> .Range("A1").ClearContents 'Clear A1 on sheet "Catalyst"
> Range("A1").ClearContents 'Clear A1 on active sheet
>
> Hopes this helps.
>
> ---
> Per
>
> "Bishop" <(E-Mail Removed)> skrev i meddelelsen
> news:B150ED0F-FAC5-41B9-A2A3-(E-Mail Removed)...
> >I have a workbook with two worksheets: Tally Sheet and Catalyst.
> > I have 2 procedures in this workbook: TallySheetRep and BanSum.
> > BanSum take a list of data and deletes all the duplicates.
> > TallySheetRep takes the same data (after BanSum runs), formats it, and
> > places in my Tally Sheet worksheet.
> > I call BanSum from TallySheetRep. Here's the problem. If I run
> > TallySheetRep while in the Catalyst worksheet everything runs fine. But
> > if I
> > run TallySheetRep while I'm in the Tally Sheet worksheet the code starts
> > deleting all the duplicate lines in the Tally Sheet worksheet. Here's the
> > basic layout of my two procedures:
> >
> > Sub TallySheetRep()
> > Call BanSum
> > With Sheets("Catalyst")
> > ...sort, edit, etc.
> > copy data to sheet Tally Sheet
> > With Sheets("Tally Sheet")
> > ...populate some formulas
> > End Sub
> >
> > Sub BanSum()
> > With Sheets("Catalyst")
> > ...sort, delete dups, etc.
> > End Sub
> >
> > It's like BanSum totally disregards 'With Sheets("Catalyst")' and runs the
> > code right on the Tally Sheet worksheet instead. Even if I'm on the Tally
> > Sheet worksheet shouldn't the BanSum code 'go to' the Catalyst worksheet
> > when
> > it's called? Why is this happening?

>
>

 
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
Sort text ignoring Titles with "The" or "A" / "An" =?Utf-8?B?S2VuIENvYmxlcg==?= Microsoft Access VBA Modules 6 24th Jun 2006 05:57 PM
after a ftp put command it just says "200 PORT command successful." and hangs forever. What could be wrong? when i test the ftp server using IE in "passive" mode it works fine. but ftp at command line hangs on "200 PORT comma Daniel Microsoft Windows 2000 Security 6 1st May 2006 02:51 PM
after a ftp put command it just says "200 PORT command successful." and hangs forever. What could be wrong? when i test the ftp server using IE in "passive" mode it works fine. but ftp at command line hangs on "200 PORT comma Daniel Microsoft Windows 2000 Networking 1 29th Apr 2006 02:42 AM
after a ftp put command it just says "200 PORT command successful." and hangs forever. What could be wrong? when i test the ftp server using IE in "passive" mode it works fine. but ftp at command line hangs on "200 PORT comma Daniel Microsoft Windows 2000 1 29th Apr 2006 02:05 AM
Sorting ignoring alpahnumeric lists ignoring "the" and "an". pbrute Microsoft Excel Discussion 7 27th Oct 2003 11:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:13 PM.