Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Called procedure ignoring "With Sheets" command

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Called procedure ignoring "With Sheets" command

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" skrev i meddelelsen
...
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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Called procedure ignoring "With Sheets" command

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" skrev i meddelelsen
...
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
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
Whats wrong with this? MyWBAccRep.Sheets("Volumes").Cells.Find("latest").Copy.Offset(0, Simon[_2_] Excel Programming 2 August 11th 08 01:29 PM
ie Command to Wait for "File Download" and "Save As" windows [email protected] Excel Programming 11 April 24th 08 11:20 AM
command button and the "enter" and "tab" keys dr chuck Excel Programming 10 September 11th 06 12:09 AM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM
Sheets("sheet1").Range command between workbooks Luc[_3_] Excel Programming 3 September 27th 05 01:03 PM


All times are GMT +1. The time now is 01:22 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"