PC Review


Reply
Thread Tools Rate Thread

Code doesn't generate correctly on two of 37 instances

 
 
=?Utf-8?B?Um9taW5hbGw=?=
Guest
Posts: n/a
 
      16th Mar 2007
Okay, this is really frustrating. I have code that auto generates 37
worksheets, copying data from a master worksheet.Then it adds some columns
and some formulas. On two of the 37 worksheets, when it adds the columns,
the column headings appear diferently. I'll try to explain and cover any
questions.

The data is for the same 37 people and the autogenerated worksheets are for
each person.

Code starts by deleting old data using the clear function. Then it imports
data and formats it. Then it autogenerates the 37 worksheets, copies the
data from the master sheet and then adds columns. here's the code for that
part.

Columns("E:E").Select
Selection.Insert Shift:=xlToRight ***(12 columns are inserted)

Range("E2").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[20]:RC[24])"
MntTot = ActiveCell.Value
ActiveCell.Offset(-1, 0).Value = "Jan " + CStr(MntTot) + ""
Range("F2").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[24]:RC[27])"
MntTot = ActiveCell.Value
ActiveCell.Offset(-1, 0).Value = "Feb " + CStr(MntTot) + ""
*****does this for all months

The code then adds two charts. It's the charts that show me the problem.
The problem on the two sheets (and it's the same two sheets everytime) is
that the column headings show up 'funny'.

The good sheets have the chart axis show up as the months plus the number
specified in the code above. The bad sheets axis' show up like this:
Feb-60, Feb-61, Feb-63 (there are 16 of these).

So why, when I'm basically starting out with new worksheets and new data
does the code mess up on only 2 of the worksheets? The worksheets are #31
and #37. I can find no 'unique' cirmcumstances for these two worksheets.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Mar 2007
Whatever MntTot is for those two sheets, it looks like a date to Excel.

You can fix it with a single quote at the beginning as below

ActiveCell.Offset(-1, 0).Value = "'Jan " + CStr(MntTot) + ""

Single quote added before Jan. The single quote won't be visible except in
the formula bar.

--
Regards,
Tom Ogilvy


"Rominall" wrote:

> Okay, this is really frustrating. I have code that auto generates 37
> worksheets, copying data from a master worksheet.Then it adds some columns
> and some formulas. On two of the 37 worksheets, when it adds the columns,
> the column headings appear diferently. I'll try to explain and cover any
> questions.
>
> The data is for the same 37 people and the autogenerated worksheets are for
> each person.
>
> Code starts by deleting old data using the clear function. Then it imports
> data and formats it. Then it autogenerates the 37 worksheets, copies the
> data from the master sheet and then adds columns. here's the code for that
> part.
>
> Columns("E:E").Select
> Selection.Insert Shift:=xlToRight ***(12 columns are inserted)
>
> Range("E2").Select
> ActiveCell.FormulaR1C1 = "=SUM(RC[20]:RC[24])"
> MntTot = ActiveCell.Value
> ActiveCell.Offset(-1, 0).Value = "Jan " + CStr(MntTot) + ""
> Range("F2").Select
> ActiveCell.FormulaR1C1 = "=SUM(RC[24]:RC[27])"
> MntTot = ActiveCell.Value
> ActiveCell.Offset(-1, 0).Value = "Feb " + CStr(MntTot) + ""
> *****does this for all months
>
> The code then adds two charts. It's the charts that show me the problem.
> The problem on the two sheets (and it's the same two sheets everytime) is
> that the column headings show up 'funny'.
>
> The good sheets have the chart axis show up as the months plus the number
> specified in the code above. The bad sheets axis' show up like this:
> Feb-60, Feb-61, Feb-63 (there are 16 of these).
>
> So why, when I'm basically starting out with new worksheets and new data
> does the code mess up on only 2 of the worksheets? The worksheets are #31
> and #37. I can find no 'unique' cirmcumstances for these two worksheets.

 
Reply With Quote
 
=?Utf-8?B?Um9taW5hbGw=?=
Guest
Posts: n/a
 
      16th Mar 2007
I just knew it would be something simple. THANKS!!

"Rominall" wrote:

> Okay, this is really frustrating. I have code that auto generates 37
> worksheets, copying data from a master worksheet.Then it adds some columns
> and some formulas. On two of the 37 worksheets, when it adds the columns,
> the column headings appear diferently. I'll try to explain and cover any
> questions.
>
> The data is for the same 37 people and the autogenerated worksheets are for
> each person.
>
> Code starts by deleting old data using the clear function. Then it imports
> data and formats it. Then it autogenerates the 37 worksheets, copies the
> data from the master sheet and then adds columns. here's the code for that
> part.
>
> Columns("E:E").Select
> Selection.Insert Shift:=xlToRight ***(12 columns are inserted)
>
> Range("E2").Select
> ActiveCell.FormulaR1C1 = "=SUM(RC[20]:RC[24])"
> MntTot = ActiveCell.Value
> ActiveCell.Offset(-1, 0).Value = "Jan " + CStr(MntTot) + ""
> Range("F2").Select
> ActiveCell.FormulaR1C1 = "=SUM(RC[24]:RC[27])"
> MntTot = ActiveCell.Value
> ActiveCell.Offset(-1, 0).Value = "Feb " + CStr(MntTot) + ""
> *****does this for all months
>
> The code then adds two charts. It's the charts that show me the problem.
> The problem on the two sheets (and it's the same two sheets everytime) is
> that the column headings show up 'funny'.
>
> The good sheets have the chart axis show up as the months plus the number
> specified in the code above. The bad sheets axis' show up like this:
> Feb-60, Feb-61, Feb-63 (there are 16 of these).
>
> So why, when I'm basically starting out with new worksheets and new data
> does the code mess up on only 2 of the worksheets? The worksheets are #31
> and #37. I can find no 'unique' cirmcumstances for these two worksheets.

 
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
Refactor or code snipple to generate a constructor based on instances variables Ignacio Machin \( .NET/ C# MVP \) Microsoft C# .NET 2 10th Feb 2008 05:27 AM
Why doesn't Print Preview doesn't show everything correctly? =?Utf-8?B?TWVlbmll?= Microsoft Excel Worksheet Functions 0 15th Mar 2007 08:00 PM
How to generate readonly attribute correctly? Hamed Microsoft ASP .NET 3 9th Jul 2006 02:23 PM
Created Date does not generate correctly =?Utf-8?B?THluZXR0ZQ==?= Microsoft Excel Misc 0 12th May 2006 07:45 AM
HELP!! Why doesn't this code sort correctly? batatoon Microsoft C# .NET 2 8th Apr 2005 08:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:58 PM.