PC Review


Reply
Thread Tools Rate Thread

Copy Columns to New Sheet

 
 
manfareed
Guest
Posts: n/a
 
      20th Dec 2007
Hi ,

I have "current month" and "Year to Date" data in columns "C" to "I"... for
each of the branches for one of our companies. I need to add a new sheet [
"All Branches"]and copy " columns C to I from each of the branch "tabs" to
the new sheet. Therefore the data from the first tab will be in Column C to I
in the new sheet and data from the 2nd tab will be copied to the next
available column after COL I [I would prefer 1 column space between 2
different branches i.e. col "K" ]in the new sheet and so on ...

One final thing ... when data is copied to the new sheet - "All Branches"
tab ... the tab name [branch name] should also be copied. For Example for
the first branch it should be copied to Range "C8" [In bold and underlined].

I cannot record the macro because the names and the number of branches
varies for each of the companies.

Hope the above makes sense.

Thanks
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      20th Dec 2007

Sub create_summary()

Worksheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "All Branches"

ColumnCount = 3 'Column C
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "All Branches" Then
sht.Columns("C:I").Copy _
Destination:=Sheets("All Branches"). _
Columns(ColumnCount)
With Sheets("All Branches").Cells(8, ColumnCount)
.Value = sht.Name
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
End With
ColumnCount = ColumnCount + 8
End If

Next sht
"manfareed" wrote:

> Hi ,
>
> I have "current month" and "Year to Date" data in columns "C" to "I"... for
> each of the branches for one of our companies. I need to add a new sheet [
> "All Branches"]and copy " columns C to I from each of the branch "tabs" to
> the new sheet. Therefore the data from the first tab will be in Column C to I
> in the new sheet and data from the 2nd tab will be copied to the next
> available column after COL I [I would prefer 1 column space between 2
> different branches i.e. col "K" ]in the new sheet and so on ...
>
> One final thing ... when data is copied to the new sheet - "All Branches"
> tab ... the tab name [branch name] should also be copied. For Example for
> the first branch it should be copied to Range "C8" [In bold and underlined].
>
> I cannot record the macro because the names and the number of branches
> varies for each of the companies.
>
> Hope the above makes sense.
>
> Thanks

 
Reply With Quote
 
manfareed
Guest
Posts: n/a
 
      20th Dec 2007
Hi Joel,

Thanks for the code ... perfect !!!

One question ...

How do I make the "sheet" "All Branches" the first tab ? It should be before
the summary sheet.

Thanks,

Manir

"Joel" wrote:

>
> Sub create_summary()
>
> Worksheets.Add after:=Sheets(Sheets.Count)
> ActiveSheet.Name = "All Branches"
>
> ColumnCount = 3 'Column C
> For Each sht In ThisWorkbook.Sheets
> If sht.Name <> "All Branches" Then
> sht.Columns("C:I").Copy _
> Destination:=Sheets("All Branches"). _
> Columns(ColumnCount)
> With Sheets("All Branches").Cells(8, ColumnCount)
> .Value = sht.Name
> .Font.Bold = True
> .Font.Underline = xlUnderlineStyleSingle
> End With
> ColumnCount = ColumnCount + 8
> End If
>
> Next sht
> "manfareed" wrote:
>
> > Hi ,
> >
> > I have "current month" and "Year to Date" data in columns "C" to "I"... for
> > each of the branches for one of our companies. I need to add a new sheet [
> > "All Branches"]and copy " columns C to I from each of the branch "tabs" to
> > the new sheet. Therefore the data from the first tab will be in Column C to I
> > in the new sheet and data from the 2nd tab will be copied to the next
> > available column after COL I [I would prefer 1 column space between 2
> > different branches i.e. col "K" ]in the new sheet and so on ...
> >
> > One final thing ... when data is copied to the new sheet - "All Branches"
> > tab ... the tab name [branch name] should also be copied. For Example for
> > the first branch it should be copied to Range "C8" [In bold and underlined].
> >
> > I cannot record the macro because the names and the number of branches
> > varies for each of the companies.
> >
> > Hope the above makes sense.
> >
> > Thanks

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      20th Dec 2007
from
Worksheets.Add after:=Sheets(Sheets.Count)
to
Worksheets.Add before:=Sheets(1)

"manfareed" wrote:

> Hi Joel,
>
> Thanks for the code ... perfect !!!
>
> One question ...
>
> How do I make the "sheet" "All Branches" the first tab ? It should be before
> the summary sheet.
>
> Thanks,
>
> Manir
>
> "Joel" wrote:
>
> >
> > Sub create_summary()
> >
> > Worksheets.Add after:=Sheets(Sheets.Count)
> > ActiveSheet.Name = "All Branches"
> >
> > ColumnCount = 3 'Column C
> > For Each sht In ThisWorkbook.Sheets
> > If sht.Name <> "All Branches" Then
> > sht.Columns("C:I").Copy _
> > Destination:=Sheets("All Branches"). _
> > Columns(ColumnCount)
> > With Sheets("All Branches").Cells(8, ColumnCount)
> > .Value = sht.Name
> > .Font.Bold = True
> > .Font.Underline = xlUnderlineStyleSingle
> > End With
> > ColumnCount = ColumnCount + 8
> > End If
> >
> > Next sht
> > "manfareed" wrote:
> >
> > > Hi ,
> > >
> > > I have "current month" and "Year to Date" data in columns "C" to "I"... for
> > > each of the branches for one of our companies. I need to add a new sheet [
> > > "All Branches"]and copy " columns C to I from each of the branch "tabs" to
> > > the new sheet. Therefore the data from the first tab will be in Column C to I
> > > in the new sheet and data from the 2nd tab will be copied to the next
> > > available column after COL I [I would prefer 1 column space between 2
> > > different branches i.e. col "K" ]in the new sheet and so on ...
> > >
> > > One final thing ... when data is copied to the new sheet - "All Branches"
> > > tab ... the tab name [branch name] should also be copied. For Example for
> > > the first branch it should be copied to Range "C8" [In bold and underlined].
> > >
> > > I cannot record the macro because the names and the number of branches
> > > varies for each of the companies.
> > >
> > > Hope the above makes sense.
> > >
> > > Thanks

 
Reply With Quote
 
manfareed
Guest
Posts: n/a
 
      21st Dec 2007
Thank You

"Joel" wrote:

> from
> Worksheets.Add after:=Sheets(Sheets.Count)
> to
> Worksheets.Add before:=Sheets(1)
>
> "manfareed" wrote:
>
> > Hi Joel,
> >
> > Thanks for the code ... perfect !!!
> >
> > One question ...
> >
> > How do I make the "sheet" "All Branches" the first tab ? It should be before
> > the summary sheet.
> >
> > Thanks,
> >
> > Manir
> >
> > "Joel" wrote:
> >
> > >
> > > Sub create_summary()
> > >
> > > Worksheets.Add after:=Sheets(Sheets.Count)
> > > ActiveSheet.Name = "All Branches"
> > >
> > > ColumnCount = 3 'Column C
> > > For Each sht In ThisWorkbook.Sheets
> > > If sht.Name <> "All Branches" Then
> > > sht.Columns("C:I").Copy _
> > > Destination:=Sheets("All Branches"). _
> > > Columns(ColumnCount)
> > > With Sheets("All Branches").Cells(8, ColumnCount)
> > > .Value = sht.Name
> > > .Font.Bold = True
> > > .Font.Underline = xlUnderlineStyleSingle
> > > End With
> > > ColumnCount = ColumnCount + 8
> > > End If
> > >
> > > Next sht
> > > "manfareed" wrote:
> > >
> > > > Hi ,
> > > >
> > > > I have "current month" and "Year to Date" data in columns "C" to "I"... for
> > > > each of the branches for one of our companies. I need to add a new sheet [
> > > > "All Branches"]and copy " columns C to I from each of the branch "tabs" to
> > > > the new sheet. Therefore the data from the first tab will be in Column C to I
> > > > in the new sheet and data from the 2nd tab will be copied to the next
> > > > available column after COL I [I would prefer 1 column space between 2
> > > > different branches i.e. col "K" ]in the new sheet and so on ...
> > > >
> > > > One final thing ... when data is copied to the new sheet - "All Branches"
> > > > tab ... the tab name [branch name] should also be copied. For Example for
> > > > the first branch it should be copied to Range "C8" [In bold and underlined].
> > > >
> > > > I cannot record the macro because the names and the number of branches
> > > > varies for each of the companies.
> > > >
> > > > Hope the above makes sense.
> > > >
> > > > Thanks

 
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
Copy specified columns to another sheet Gemz Microsoft Excel Programming 8 3rd Feb 2008 01:46 PM
copy different columns from sheet to other sheet p. panter Microsoft Excel Programming 1 9th Feb 2006 05:23 PM
Copy certain columns to another sheet using a macro Shane Nation Microsoft Excel Programming 2 24th Sep 2005 05:36 PM
Re: Copy a row from one sheet to another and not all columns copy Peaches Microsoft Excel Programming 0 7th Sep 2005 12:09 PM
macro to copy columns to sheet Es Microsoft Excel Misc 1 7th Mar 2005 02:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:59 AM.