Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 12
Default Copy Total to the following row in Column A

Hi, I'm working on a list of vendor names and the total in Column A.
For example:

Rows
1 Name A
2 Name B
3 Name C
4 Total Spend - Cars
5

I want row 5 to copy row 4 but it would display "Total N Spend - Cars"
So for each row that contains "Total Spend" copy it to the following
row and add the name N between Total and Spend. So another example
would be if row 8 show, Total Spend - Apples, then row 9 would display
Total N Spend - Apples. I'm still very new to these macro codes. Any
help would greatly be appreciated. Thanks so much.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Copy Total to the following row in Column A

Many ways of doing it, but the one I'm most familiar with is Looping.
Note, this assumes that every cell above is populated. If there's a
chance that you won't start from Row 1 or there may be blanks, let me
know and I'll code it more robustly.

Sub TotalSpend()

Dim iCount As Integer
Dim iMax As Integer
Dim iLength As Integer

iCount = 1
iMax = WorksheetFunction.CountA(Sheets("Sheet1").Columns( 1))

Do Until Left(Sheets("Sheet1").Cells(iCount, 1).Value, 11) = "Total
Spend"
iCount = iCount + 1
Select Case iCount
Case Is iMax
MsgBox "Some data must be missing in Column A of Sheet1."
Exit Sub
End Select
Loop

iLength = Len(Sheets("Sheet1").Cells(iCount, 1).Value)

Sheets("Sheet1").Cells(iCount + 1, 1).Value = "Total N Spend - " & _
Right(Sheets("Sheet1").Cells(iCount, 1).Value, iLength - 14)

End Sub

Sure you want just an N in there? Could easily put in the number of
entries above the first instance of Total Spend.

Hope this helps,

Ross.

dd wrote:
Hi, I'm working on a list of vendor names and the total in Column A.
For example:

Rows
1 Name A
2 Name B
3 Name C
4 Total Spend - Cars
5

I want row 5 to copy row 4 but it would display "Total N Spend - Cars"
So for each row that contains "Total Spend" copy it to the following
row and add the name N between Total and Spend. So another example
would be if row 8 show, Total Spend - Apples, then row 9 would display
Total N Spend - Apples. I'm still very new to these macro codes. Any
help would greatly be appreciated. Thanks so much.


  #3   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 12
Default Copy Total to the following row in Column A

Hi Ross,

My data starts on row #6 and ends on row 3200. I highlighted all the
data in column A and there are no spaces in between, then I ran the
code you provided. But a "compile error was encounter, sub or function
not defined." Not sure what to do. Also the N would be used for a name
I would be putting in later.
Thanks for your help.
dd


Rawce wrote:
Many ways of doing it, but the one I'm most familiar with is Looping.
Note, this assumes that every cell above is populated. If there's a
chance that you won't start from Row 1 or there may be blanks, let me
know and I'll code it more robustly.

Sub TotalSpend()

Dim iCount As Integer
Dim iMax As Integer
Dim iLength As Integer

iCount = 1
iMax = WorksheetFunction.CountA(Sheets("Sheet1").Columns( 1))

Do Until Left(Sheets("Sheet1").Cells(iCount, 1).Value, 11) = "Total
Spend"
iCount = iCount + 1
Select Case iCount
Case Is iMax
MsgBox "Some data must be missing in Column A of Sheet1."
Exit Sub
End Select
Loop

iLength = Len(Sheets("Sheet1").Cells(iCount, 1).Value)

Sheets("Sheet1").Cells(iCount + 1, 1).Value = "Total N Spend - " & _
Right(Sheets("Sheet1").Cells(iCount, 1).Value, iLength - 14)

End Sub

Sure you want just an N in there? Could easily put in the number of
entries above the first instance of Total Spend.

Hope this helps,

Ross.

dd wrote:
Hi, I'm working on a list of vendor names and the total in Column A.
For example:

Rows
1 Name A
2 Name B
3 Name C
4 Total Spend - Cars
5

I want row 5 to copy row 4 but it would display "Total N Spend - Cars"
So for each row that contains "Total Spend" copy it to the following
row and add the name N between Total and Spend. So another example
would be if row 8 show, Total Spend - Apples, then row 9 would display
Total N Spend - Apples. I'm still very new to these macro codes. Any
help would greatly be appreciated. Thanks so much.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Copy Total to the following row in Column A

Sorry, was away over Christmas and New Year without much Internet
access.

Does the compile error point to this line:
Do Until Left(Sheets("Sheet1").Cells(iCount, 1).Value, 11) = "Total
Spend"

If so, all that should be on a single line as the text was wrapped by
the Groups text window. If not, let me know and I'll have a look.

I think you can start from Row 6 by changing iCount = 1 to iCount = 6.

Let me know how you get on, and sorry again for the delay.

Cheers,

Ross.

dd wrote:
Hi Ross,

My data starts on row #6 and ends on row 3200. I highlighted all the
data in column A and there are no spaces in between, then I ran the
code you provided. But a "compile error was encounter, sub or function
not defined." Not sure what to do. Also the N would be used for a name
I would be putting in later.
Thanks for your help.
dd


Rawce wrote:
Many ways of doing it, but the one I'm most familiar with is Looping.
Note, this assumes that every cell above is populated. If there's a
chance that you won't start from Row 1 or there may be blanks, let me
know and I'll code it more robustly.

Sub TotalSpend()

Dim iCount As Integer
Dim iMax As Integer
Dim iLength As Integer

iCount = 1
iMax = WorksheetFunction.CountA(Sheets("Sheet1").Columns( 1))

Do Until Left(Sheets("Sheet1").Cells(iCount, 1).Value, 11) = "Total
Spend"
iCount = iCount + 1
Select Case iCount
Case Is iMax
MsgBox "Some data must be missing in Column A of Sheet1."
Exit Sub
End Select
Loop

iLength = Len(Sheets("Sheet1").Cells(iCount, 1).Value)

Sheets("Sheet1").Cells(iCount + 1, 1).Value = "Total N Spend - " & _
Right(Sheets("Sheet1").Cells(iCount, 1).Value, iLength - 14)

End Sub

Sure you want just an N in there? Could easily put in the number of
entries above the first instance of Total Spend.

Hope this helps,

Ross.

dd wrote:
Hi, I'm working on a list of vendor names and the total in Column A.
For example:

Rows
1 Name A
2 Name B
3 Name C
4 Total Spend - Cars
5

I want row 5 to copy row 4 but it would display "Total N Spend - Cars"
So for each row that contains "Total Spend" copy it to the following
row and add the name N between Total and Spend. So another example
would be if row 8 show, Total Spend - Apples, then row 9 would display
Total N Spend - Apples. I'm still very new to these macro codes. Any
help would greatly be appreciated. Thanks so much.


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
Count number of cells and total in one column, based on another column suffix Pierre Excel Worksheet Functions 5 October 31st 07 12:28 AM
Total column changes colors when total equals sum of other columns newstacy New Users to Excel 1 April 21st 07 09:00 PM
disable Total and/or Sub total for a single column Voyager Excel Worksheet Functions 3 February 14th 07 10:51 PM
XL formula - total of row = total of column topaz Excel Worksheet Functions 2 March 17th 05 10:04 PM


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