Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Pasting two named tabs one below the other

What I have is a work book with named tabs that i need to make a macro for
that will take the data from two different pages and paste it to another
page that would have the combined data of the pasted pages. The amount of
data can very as well that is on each page. I would also like to be able to
have it place a total line blow the pasted data for each of the pasted
columns. Please help.

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default Pasting two named tabs one below the other

hi jln

have built you something:

It's designed for a Workbook with 3 sheets which are named:
"1","2" and "3", if you want to summarize more then 2 sheets
you just have to enlarge the array!
'---------------------------------------------
Sub summarizer()

Dim i As Integer
i = 1

Dim arr_sheets(1) As String

arr_sheets(0) = "1" '1st Sheet
arr_sheets(1) = "2"'2nd Sheet

For j = 0 To 1
For Each row_ In Sheets(arr_sheets(j)).Rows
Debug.Print row_.Cells(1, 1)

If row_.Cells(1, 1) < "" Then
row_.Copy
Worksheets("3").Rows(i).Insert 'Insert in 3rd sheet
i = i + 1
Else
Exit For
End If

Next row_
Next j


'Total at the End
For k = 1 To 256
If Worksheets("3").Cells(i - 1, k) < "" Then
Worksheets("3").Cells(i, k).FormulaR1C1 = "=SUM(R1C" & k & ":R" & i
- 1 & "C" & k & ")"
Else
Exit For
End If
Next k

End Sub
'------------------------------------------------------
Hth

Cheers Carlo


"jln via OfficeKB.com" wrote:

What I have is a work book with named tabs that i need to make a macro for
that will take the data from two different pages and paste it to another
page that would have the combined data of the pasted pages. The amount of
data can very as well that is on each page. I would also like to be able to
have it place a total line blow the pasted data for each of the pasted
columns. Please help.

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Pasting two named tabs one below the other

Carlo the code looks great
Im getting an app defined or object error
Sub Test()
Dim i As Integer
i = 1

Dim arr_sheets(1) As String

arr_sheets(0) = "MGICLPMI" '1st Sheet
arr_sheets(1) = "RMICLPMI" '2nd Sheet

For j = 0 To 1
For Each row_ In Sheets(arr_sheets(j)).Rows
Debug.Print row_.Cells(1, 1)

If row_.Cells(1, 1) < "" Then
row_.Copy
Worksheets("Combine LPMI").Rows(i).Insert 'Insert in 3rd sheet
i = i + 1
Else
Exit For
End If

Next row_
Next j

'Total at the End
For k = 1 To 256

If Worksheets("Combine LPMI").Cells(i - 1, k) < "" Then
' Here is where im getting the probelm I dont see why it shouldnt work.

Worksheets("Combine LPMI").Cells(i, k).FormulaR1C1 = "=SUM(R1C" & k &
":R" & i - 1 & "C" & k & ")"
Else
Exit For
End If
Next k
End Sub

--
Message posted via http://www.officekb.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default Pasting two named tabs one below the other

hmm...thats strange, the first time you refer to your 3rd Worksheet,
it works!!

some questions to evaluate the problem:
What value does "i"/"k" have on the position where you get the error?
what do you get if put following lines in front of the if, where the error
comes:
debug.print Worksheets("Combine LPMI").Cells(i - 1, k)
debug.print Worksheets("Combine LPMI").Name

hope this helps to resolve the issue

Carlo

"jln via OfficeKB.com" wrote:

Carlo the code looks great
Im getting an app defined or object error
Sub Test()
Dim i As Integer
i = 1

Dim arr_sheets(1) As String

arr_sheets(0) = "MGICLPMI" '1st Sheet
arr_sheets(1) = "RMICLPMI" '2nd Sheet

For j = 0 To 1
For Each row_ In Sheets(arr_sheets(j)).Rows
Debug.Print row_.Cells(1, 1)

If row_.Cells(1, 1) < "" Then
row_.Copy
Worksheets("Combine LPMI").Rows(i).Insert 'Insert in 3rd sheet
i = i + 1
Else
Exit For
End If

Next row_
Next j

'Total at the End
For k = 1 To 256

If Worksheets("Combine LPMI").Cells(i - 1, k) < "" Then
' Here is where im getting the probelm I dont see why it shouldnt work.

Worksheets("Combine LPMI").Cells(i, k).FormulaR1C1 = "=SUM(R1C" & k &
":R" & i - 1 & "C" & k & ")"
Else
Exit For
End If
Next k
End Sub

--
Message posted via http://www.officekb.com


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Pasting two named tabs one below the other

Carlo Thanks I got it working it was a mistake on my end not the code.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200609/1

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
How can I alphabetize re-named tabs on Excel? Wil Excel Discussion (Misc queries) 1 November 26th 09 12:21 AM
Relative reference for named tabs? Dave in Fair Oaks Excel Worksheet Functions 6 June 19th 07 06:21 PM
Copy & pasting formulas across workbook tabs Anne Reichler Excel Worksheet Functions 1 June 7th 07 09:25 PM
I cannot review my named sheet tabs on my spreadsheet ctaylor Excel Worksheet Functions 8 December 28th 06 10:31 PM
Create tabs named after a group of cells? BM Excel Discussion (Misc queries) 3 September 26th 06 09:21 PM


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