Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Help adding a label to Total line

my code works fine with the total line, but when I added the label in column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Help adding a label to Total line

lastrow = Range("A65536").End(xlUp).Row + 1
Sheet1.Range("A" & lastrow).Value = "Total Outstanding at Month End"



"marcia2026" wrote in message
...
my code works fine with the total line, but when I added the label in
column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Help adding a label to Total line

It still bugs on the 1st line.

"Bob Umlas" wrote:

lastrow = Range("A65536").End(xlUp).Row + 1
Sheet1.Range("A" & lastrow).Value = "Total Outstanding at Month End"



"marcia2026" wrote in message
...
my code works fine with the total line, but when I added the label in
column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help adding a label to Total line

I'm not sure what bugged out means, but if you have gaps in column A, then using
..end(xldown) may not be a good choice.

I like
with activesheet
.cells(.rows.count,"A").end(xlup).offset(1,0)
....
(starting from the bottom

If bugging out means that the totals go on the row below that total string,
maybe...

Cells(1, 1).End(xlDown).Offset(1, 0).Range("F1,H1,I1").FormulaR1C1 _
= "=Sum(R2C:R[-1]C)"

marcia2026 wrote:

my code works fine with the total line, but when I added the label in column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Help adding a label to Total line

The code you have may or may not do what you want depending on which sheet is
the active sheet... Try using a range object to hold the spot where you want
to make the changes...

dim rng as range

set rng = sheet1.cells(rows.count, "a").end(xlup).offset(1,0)
rng.value = "Total Outstanding at Month End"
rng.offset(0,1).FormulaR1C1 = "=Sum(R2C:R[-1]C)" 'not sure what you want here

--
HTH...

Jim Thomlinson


"marcia2026" wrote:

my code works fine with the total line, but when I added the label in column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Help adding a label to Total line

sorry, I am new to this. When I said that it bugged out, I meant that the
code stopped working at that point and went to the debugger. Lastrow was
what was highlighted with a message about a compile error. What I want to do
is to create a worksheet with a variable number of lines with a total at the
end. It was working fine until I tried to add the "Total at month end" That
cell was empty. so i added the code just above my code for my totals. If i
take that part out it works ok. Here is the whole code

Sub CreateEndingWorkbook()
'
'
'Delete Outstanding worksheet

Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets("Outstanding").Delete
On Error GoTo 0
Application.DisplayAlerts = True

'Create new Outstanding worksheet with most recent data

Sheets("TotalForMonth").Select
Sheets("TotalForMonth").Copy Befo=Sheets(1)
Sheets("TotalForMonth (2)").Select
Sheets("TotalForMonth (2)").Name = "Outstanding"

Application.Run "PERSONAL.XLS!DeleteCleared" '<<<< see below

'Add label for last row

LastRow = Range("A65536").End(xlUp).Row + 1
Sheet("Outstanding").Range("A" & LastRow).Value = "Total Outstanding at
Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub

Sub DeleteCleared()
'will delete a rows that have been resolved
Dim LastRow As Long
Dim Row As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
For Row = LastRow To 1 Step -1
If Cells(Row, "G") = "R" Then
Rows(Row).Delete
End If
Next Row

End Sub
"Jim Thomlinson" wrote:

The code you have may or may not do what you want depending on which sheet is
the active sheet... Try using a range object to hold the spot where you want
to make the changes...

dim rng as range

set rng = sheet1.cells(rows.count, "a").end(xlup).offset(1,0)
rng.value = "Total Outstanding at Month End"
rng.offset(0,1).FormulaR1C1 = "=Sum(R2C:R[-1]C)" 'not sure what you want here

--
HTH...

Jim Thomlinson


"marcia2026" wrote:

my code works fine with the total line, but when I added the label in column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help adding a label to Total line

You did have a typo in this line:

Sheet("Outstanding").Range("A" & LastRow).Value _
= "Total Outstanding at Month End"

It's SheetS (with that final S)

Sheets("Outstanding").Range("A" & LastRow).Value _
= "Total Outstanding at Month End"

Is that the line that was causing the error?


marcia2026 wrote:

sorry, I am new to this. When I said that it bugged out, I meant that the
code stopped working at that point and went to the debugger. Lastrow was
what was highlighted with a message about a compile error. What I want to do
is to create a worksheet with a variable number of lines with a total at the
end. It was working fine until I tried to add the "Total at month end" That
cell was empty. so i added the code just above my code for my totals. If i
take that part out it works ok. Here is the whole code

Sub CreateEndingWorkbook()
'
'
'Delete Outstanding worksheet

Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets("Outstanding").Delete
On Error GoTo 0
Application.DisplayAlerts = True

'Create new Outstanding worksheet with most recent data

Sheets("TotalForMonth").Select
Sheets("TotalForMonth").Copy Befo=Sheets(1)
Sheets("TotalForMonth (2)").Select
Sheets("TotalForMonth (2)").Name = "Outstanding"

Application.Run "PERSONAL.XLS!DeleteCleared" '<<<< see below

'Add label for last row

LastRow = Range("A65536").End(xlUp).Row + 1
Sheet("Outstanding").Range("A" & LastRow).Value = "Total Outstanding at
Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub

Sub DeleteCleared()
'will delete a rows that have been resolved
Dim LastRow As Long
Dim Row As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
For Row = LastRow To 1 Step -1
If Cells(Row, "G") = "R" Then
Rows(Row).Delete
End If
Next Row

End Sub
"Jim Thomlinson" wrote:

The code you have may or may not do what you want depending on which sheet is
the active sheet... Try using a range object to hold the spot where you want
to make the changes...

dim rng as range

set rng = sheet1.cells(rows.count, "a").end(xlup).offset(1,0)
rng.value = "Total Outstanding at Month End"
rng.offset(0,1).FormulaR1C1 = "=Sum(R2C:R[-1]C)" 'not sure what you want here

--
HTH...

Jim Thomlinson


"marcia2026" wrote:

my code works fine with the total line, but when I added the label in column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help adding a label to Total line

ps. Share the complete error message and the line that caused the error.

marcia2026 wrote:

sorry, I am new to this. When I said that it bugged out, I meant that the
code stopped working at that point and went to the debugger. Lastrow was
what was highlighted with a message about a compile error. What I want to do
is to create a worksheet with a variable number of lines with a total at the
end. It was working fine until I tried to add the "Total at month end" That
cell was empty. so i added the code just above my code for my totals. If i
take that part out it works ok. Here is the whole code

Sub CreateEndingWorkbook()
'
'
'Delete Outstanding worksheet

Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets("Outstanding").Delete
On Error GoTo 0
Application.DisplayAlerts = True

'Create new Outstanding worksheet with most recent data

Sheets("TotalForMonth").Select
Sheets("TotalForMonth").Copy Befo=Sheets(1)
Sheets("TotalForMonth (2)").Select
Sheets("TotalForMonth (2)").Name = "Outstanding"

Application.Run "PERSONAL.XLS!DeleteCleared" '<<<< see below

'Add label for last row

LastRow = Range("A65536").End(xlUp).Row + 1
Sheet("Outstanding").Range("A" & LastRow).Value = "Total Outstanding at
Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub

Sub DeleteCleared()
'will delete a rows that have been resolved
Dim LastRow As Long
Dim Row As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
For Row = LastRow To 1 Step -1
If Cells(Row, "G") = "R" Then
Rows(Row).Delete
End If
Next Row

End Sub
"Jim Thomlinson" wrote:

The code you have may or may not do what you want depending on which sheet is
the active sheet... Try using a range object to hold the spot where you want
to make the changes...

dim rng as range

set rng = sheet1.cells(rows.count, "a").end(xlup).offset(1,0)
rng.value = "Total Outstanding at Month End"
rng.offset(0,1).FormulaR1C1 = "=Sum(R2C:R[-1]C)" 'not sure what you want here

--
HTH...

Jim Thomlinson


"marcia2026" wrote:

my code works fine with the total line, but when I added the label in column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Help adding a label to Total line

You guys are terrific!!!
When I corrected the typo everything worked fine. Thanks so much!
"Dave Peterson" wrote:

ps. Share the complete error message and the line that caused the error.

marcia2026 wrote:

sorry, I am new to this. When I said that it bugged out, I meant that the
code stopped working at that point and went to the debugger. Lastrow was
what was highlighted with a message about a compile error. What I want to do
is to create a worksheet with a variable number of lines with a total at the
end. It was working fine until I tried to add the "Total at month end" That
cell was empty. so i added the code just above my code for my totals. If i
take that part out it works ok. Here is the whole code

Sub CreateEndingWorkbook()
'
'
'Delete Outstanding worksheet

Application.DisplayAlerts = False
On Error Resume Next
ActiveWorkbook.Worksheets("Outstanding").Delete
On Error GoTo 0
Application.DisplayAlerts = True

'Create new Outstanding worksheet with most recent data

Sheets("TotalForMonth").Select
Sheets("TotalForMonth").Copy Befo=Sheets(1)
Sheets("TotalForMonth (2)").Select
Sheets("TotalForMonth (2)").Name = "Outstanding"

Application.Run "PERSONAL.XLS!DeleteCleared" '<<<< see below

'Add label for last row

LastRow = Range("A65536").End(xlUp).Row + 1
Sheet("Outstanding").Range("A" & LastRow).Value = "Total Outstanding at
Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub

Sub DeleteCleared()
'will delete a rows that have been resolved
Dim LastRow As Long
Dim Row As Long
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
For Row = LastRow To 1 Step -1
If Cells(Row, "G") = "R" Then
Rows(Row).Delete
End If
Next Row

End Sub
"Jim Thomlinson" wrote:

The code you have may or may not do what you want depending on which sheet is
the active sheet... Try using a range object to hold the spot where you want
to make the changes...

dim rng as range

set rng = sheet1.cells(rows.count, "a").end(xlup).offset(1,0)
rng.value = "Total Outstanding at Month End"
rng.offset(0,1).FormulaR1C1 = "=Sum(R2C:R[-1]C)" 'not sure what you want here

--
HTH...

Jim Thomlinson


"marcia2026" wrote:

my code works fine with the total line, but when I added the label in column
A it bugged out. What is wrong with code?

'Add label for last row

lastrow = Range("A65536").End(xlUp).Row
lastrow = lastrow + 1
Sheet1.Range("A" & lastrow) = "Total Outstanding at Month End"

'Add totals to report

Cells(1, 1).End(xlDown).Offset(1, 0).Range( _
"F2,H2,I2").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

End Sub


--

Dave Peterson

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
Problem adding vertical marker line to line chart lbb Charts and Charting in Excel 6 January 9th 09 09:02 AM
add total from 6 textboxes and put in label pswanie Excel Programming 4 January 20th 08 06:48 PM
How can I change the label of the total fields in a pivot table? GG Excel Discussion (Misc queries) 1 July 2nd 06 02:26 PM
Adding Data Using Multiple Worksheets to Total into a Grand Total Lillie Excel Worksheet Functions 1 April 19th 05 08:34 PM
Adding a text label to a line. Neil Charts and Charting in Excel 1 December 4th 04 08:41 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"