Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Macro to copy only used cells

Hi, I have a macro which takes one 20000 line weeksheet, containing data
from 300 branches, and copies, pastes and saves to 300 new workbook
containing the data for each branch.

Each branch has a vaying number of lines of data, so my macro filters by
branch code, then copies the whole worksheet, including blank space.

this creates 4mb files, whereas if I manually copy and paste only the used
area of the workbook, it's less than 100k.

I therefore need a macro to highlight only the occupied cells. The number of
columns will always be the same (26), but number of rows varies.

Any ideas how to do this ?

--
Rich
http://www.richdavies.com/excel.htm


** Posted from http://www.teranews.com **
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Macro to copy only used cells

Does each new worksheet therefore contain all of the data for all branches?

--
__________________________________
HTH

Bob

"Rich" wrote in message
...
Hi, I have a macro which takes one 20000 line weeksheet, containing data
from 300 branches, and copies, pastes and saves to 300 new workbook
containing the data for each branch.

Each branch has a vaying number of lines of data, so my macro filters by
branch code, then copies the whole worksheet, including blank space.

this creates 4mb files, whereas if I manually copy and paste only the used
area of the workbook, it's less than 100k.

I therefore need a macro to highlight only the occupied cells. The number
of columns will always be the same (26), but number of rows varies.

Any ideas how to do this ?

--
Rich
http://www.richdavies.com/excel.htm


** Posted from http://www.teranews.com **



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Macro to copy only used cells


"Bob Phillips" wrote in message
...
Does each new worksheet therefore contain all of the data for all
branches?

--
__________________________________
HTH

Bob

"Rich" wrote in message
...
Hi, I have a macro which takes one 20000 line weeksheet, containing data
from 300 branches, and copies, pastes and saves to 300 new workbook
containing the data for each branch.

Each branch has a vaying number of lines of data, so my macro filters by
branch code, then copies the whole worksheet, including blank space.

this creates 4mb files, whereas if I manually copy and paste only the
used area of the workbook, it's less than 100k.

I therefore need a macro to highlight only the occupied cells. The number
of columns will always be the same (26), but number of rows varies.

Any ideas how to do this ?

--
Rich
http://www.richdavies.com/excel.htm


** Posted from http://www.teranews.com **




No,

The original worksheet contains 300 branches in 20000 rows.

My macro filters by each branch before copying, pasting and saving.

The new workbooks each contain only one branches data, and are named branch
A, Branch B.

--
Rich
http://www.richdavies.com/excel.htm





** Posted from http://www.teranews.com **
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Macro to copy only used cells

Then I am confused as to why it grows so big, I would only expect a doubling
(plus some for overheads), nowhere near 40 times.

--
__________________________________
HTH

Bob

"Rich" wrote in message
...

"Bob Phillips" wrote in message
...
Does each new worksheet therefore contain all of the data for all
branches?

--
__________________________________
HTH

Bob

"Rich" wrote in message
...
Hi, I have a macro which takes one 20000 line weeksheet, containing data
from 300 branches, and copies, pastes and saves to 300 new workbook
containing the data for each branch.

Each branch has a vaying number of lines of data, so my macro filters by
branch code, then copies the whole worksheet, including blank space.

this creates 4mb files, whereas if I manually copy and paste only the
used area of the workbook, it's less than 100k.

I therefore need a macro to highlight only the occupied cells. The
number of columns will always be the same (26), but number of rows
varies.

Any ideas how to do this ?

--
Rich
http://www.richdavies.com/excel.htm


** Posted from http://www.teranews.com **




No,

The original worksheet contains 300 branches in 20000 rows.

My macro filters by each branch before copying, pasting and saving.

The new workbooks each contain only one branches data, and are named
branch A, Branch B.

--
Rich
http://www.richdavies.com/excel.htm





** Posted from http://www.teranews.com **



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Macro to copy only used cells


"Bob Phillips" wrote in message
...
Then I am confused as to why it grows so big, I would only expect a
doubling (plus some for overheads), nowhere near 40 times.

--
__________________________________
HTH

Bob

"Rich" wrote in message
...

"Bob Phillips" wrote in message
...
Does each new worksheet therefore contain all of the data for all
branches?

--
__________________________________
HTH

Bob

"Rich" wrote in message
...
Hi, I have a macro which takes one 20000 line weeksheet, containing
data from 300 branches, and copies, pastes and saves to 300 new
workbook containing the data for each branch.

Each branch has a vaying number of lines of data, so my macro filters
by branch code, then copies the whole worksheet, including blank space.

this creates 4mb files, whereas if I manually copy and paste only the
used area of the workbook, it's less than 100k.

I therefore need a macro to highlight only the occupied cells. The
number of columns will always be the same (26), but number of rows
varies.

Any ideas how to do this ?

--
Rich
http://www.richdavies.com/excel.htm


** Posted from http://www.teranews.com **



No,

The original worksheet contains 300 branches in 20000 rows.

My macro filters by each branch before copying, pasting and saving.

The new workbooks each contain only one branches data, and are named
branch A, Branch B.

--
Rich
http://www.richdavies.com/excel.htm





** Posted from http://www.teranews.com **



It does end up 4 meg, whereas if I do the same thing manually, but only
highlight and copy the occupied cells, it's a little as 50k.

The branches download their 4mb files on a really slow network, so anxious
to resolve this.

Can anyone suggest a quick and dirty macro to copy only the populated cells,
or even just scroll down to the last row, and I'll work it from there.

--
Rich
http://www.richdavies.com/excel.htm


** Posted from http://www.teranews.com **


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Macro to copy only used cells

I have a macro which does the same work as yours (on a smaller scale) and it
works no problem (creating small files). Can you post your code so I can see
how it compares to mine?

"Rich" wrote:


"Bob Phillips" wrote in message
...
Does each new worksheet therefore contain all of the data for all
branches?

--
__________________________________
HTH

Bob

"Rich" wrote in message
...
Hi, I have a macro which takes one 20000 line weeksheet, containing data
from 300 branches, and copies, pastes and saves to 300 new workbook
containing the data for each branch.

Each branch has a vaying number of lines of data, so my macro filters by
branch code, then copies the whole worksheet, including blank space.

this creates 4mb files, whereas if I manually copy and paste only the
used area of the workbook, it's less than 100k.

I therefore need a macro to highlight only the occupied cells. The number
of columns will always be the same (26), but number of rows varies.

Any ideas how to do this ?

--
Rich
http://www.richdavies.com/excel.htm


** Posted from http://www.teranews.com **




No,

The original worksheet contains 300 branches in 20000 rows.

My macro filters by each branch before copying, pasting and saving.

The new workbooks each contain only one branches data, and are named branch
A, Branch B.

--
Rich
http://www.richdavies.com/excel.htm





** Posted from http://www.teranews.com **

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Macro to copy only used cells


"Wullie" wrote in message
...
I have a macro which does the same work as yours (on a smaller scale) and
it
works no problem (creating small files). Can you post your code so I can
see
how it compares to mine?





Here's the code:-

FERDCOPY()
'
' FERDCOPY Macro
' Macro recorded 02/09/2008 by Richard
'

'
Cells.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Columns("E:E").ColumnWidth = 2
Columns("G:G").ColumnWidth = 2
Columns("I:I").ColumnWidth = 2
Columns("K:K").ColumnWidth = 2
Columns("M:M").ColumnWidth = 2
Columns("O:O").ColumnWidth = 2
Columns("Q:Q").ColumnWidth = 2
Columns("S:S").ColumnWidth = 2
Columns("U:AB").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
Application.CutCopyMode = False
With ActiveSheet.pagesetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.pagesetup.PrintArea = ""
With ActiveSheet.pagesetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub
Sub FERDSAVE()
'
' FERDSAVE Macro
' Macro recorded 02/09/2008 by Richard
'
' Keyboard Shortcut: Ctrl+n
'




ChDir "C:\Documents and Settings\Richard\Desktop\New Folder\FERD\SEP
FERD\FERD SF"
Dim WS As Worksheet
Set WS = ActiveSheet
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs WS.Range("B6") _
, FileFormat:=xlNormal, Password:="deleted",
WriteResPassword:="modify", _
ReadOnlyRecommended:=True, CreateBackup:=False
ActiveWindow.Close
End Sub

Sub FERDRUN()
'
' FERDRUN Macro
' Macro recorded 02/09/2008 by Richard
'
' Keyboard Shortcut: Ctrl+u
'
Range("A1").Select
Application.Run "PERSONAL.XLS!FERDCOPY"
Application.Run "PERSONAL.XLS!FERDSAVE"
End Sub

--
Rich
http://www.richdavies.com/excel.htm
http://www.richdaviescom/fantasy-football.htm



** Posted from http://www.teranews.com **
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Macro to copy only used cells


"Rich" wrote in message
...

"Wullie" wrote in message
...
I have a macro which does the same work as yours (on a smaller scale) and
it
works no problem (creating small files). Can you post your code so I can
see
how it compares to mine?





Here's the code:-

FERDCOPY()
'
' FERDCOPY Macro
' Macro recorded 02/09/2008 by Richard
'

'
Cells.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Columns("A:A").Select
Selection.EntireColumn.Hidden = True
Columns("E:E").ColumnWidth = 2
Columns("G:G").ColumnWidth = 2
Columns("I:I").ColumnWidth = 2
Columns("K:K").ColumnWidth = 2
Columns("M:M").ColumnWidth = 2
Columns("O:O").ColumnWidth = 2
Columns("Q:Q").ColumnWidth = 2
Columns("S:S").ColumnWidth = 2
Columns("U:AB").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
Application.CutCopyMode = False
With ActiveSheet.pagesetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.pagesetup.PrintArea = ""
With ActiveSheet.pagesetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub
Sub FERDSAVE()
'
' FERDSAVE Macro
' Macro recorded 02/09/2008 by Richard
'
' Keyboard Shortcut: Ctrl+n
'




ChDir "C:\Documents and Settings\Richard\Desktop\New Folder\FERD\SEP
FERD\FERD SF"
Dim WS As Worksheet
Set WS = ActiveSheet
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs WS.Range("B6") _
, FileFormat:=xlNormal, Password:="deleted",
WriteResPassword:="modify", _
ReadOnlyRecommended:=True, CreateBackup:=False
ActiveWindow.Close
End Sub

Sub FERDRUN()
'
' FERDRUN Macro
' Macro recorded 02/09/2008 by Richard
'
' Keyboard Shortcut: Ctrl+u
'
Range("A1").Select
Application.Run "PERSONAL.XLS!FERDCOPY"
Application.Run "PERSONAL.XLS!FERDSAVE"
End Sub



I then run this for branches 1 to 300 :-

Selection.AutoFilter Field:=2, Criteria1:="BRANCH1"
Application.Run "FERDRUN"

Selection.AutoFilter Field:=2, Criteria1:="BRANCH2"
Application.Run "FERDRUN"

Selection.AutoFilter Field:=2, Criteria1:="BRANCH3"
Application.Run "FERDRUN"

I could do with knowing a better way to do this, I'll ask this as a seperate
thread.
--
Rich
http://www.richdavies.com/excel.htm
http://www.richdavies.com/fantasy-football.htm


** Posted from http://www.teranews.com **
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
Need a macro to copy cells pcor New Users to Excel 4 May 4th 09 04:24 AM
macro needed to copy blocks of cells across to list of cells down piersonpro Excel Programming 3 March 28th 07 12:51 PM
Using a macro to copy certain cells fullers Excel Programming 0 September 15th 05 04:08 PM
copy cells with a macro... John Keith[_2_] Excel Programming 6 March 11th 05 08:20 PM
a script/macro to copy a block of cells next to specified cells z.entropic[_2_] Excel Programming 8 November 14th 03 03:17 PM


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

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"