Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VBA/Macro help

All

I have a worksheet which has various col, what I would like to do is
to be able to create a new worksheet dependant on data in COL D so
for
example i would like to be able to split Apples into one worksheet
and
then Pears ( along with the 40 other cols which relate to apples or
pears)


184 apple
207 apple
208 apple
209 apple
184 Pears
207 Pears
208 Pears
209 Pears


At first i thought pivot table but as i have to do this twice a month
i thought VBA/marco - the previous person used to copy and paste and
i
think that just a waste of time.!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA/Macro help


Check your other post.

WYMMIY wrote:

All

I have a worksheet which has various col, what I would like to do is
to be able to create a new worksheet dependant on data in COL D so
for
example i would like to be able to split Apples into one worksheet
and
then Pears ( along with the 40 other cols which relate to apples or
pears)

184 apple
207 apple
208 apple
209 apple
184 Pears
207 Pears
208 Pears
209 Pears

At first i thought pivot table but as i have to do this twice a month
i thought VBA/marco - the previous person used to copy and paste and
i
think that just a waste of time.!!!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA/Macro help

I couldn't find any other posting at the microsoft site. Is this request
posted at a different site? People shouldn't post at multiple sites.

"Dave Peterson" wrote:

Check your other post.

WYMMIY wrote:

All

I have a worksheet which has various col, what I would like to do is
to be able to create a new worksheet dependant on data in COL D so
for
example i would like to be able to split Apples into one worksheet
and
then Pears ( along with the 40 other cols which relate to apples or
pears)

184 apple
207 apple
208 apple
209 apple
184 Pears
207 Pears
208 Pears
209 Pears

At first i thought pivot table but as i have to do this twice a month
i thought VBA/marco - the previous person used to copy and paste and
i
think that just a waste of time.!!!


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA/Macro help

Check:

From: Mistry
Newsgroups: microsoft.public.excel
Subject: Create new worksheet dependant on data
Date: Mon, 6 Jul 2009 04:18:49 -0700 (PDT)


Joel wrote:

I couldn't find any other posting at the microsoft site. Is this request
posted at a different site? People shouldn't post at multiple sites.

"Dave Peterson" wrote:

Check your other post.

WYMMIY wrote:

All

I have a worksheet which has various col, what I would like to do is
to be able to create a new worksheet dependant on data in COL D so
for
example i would like to be able to split Apples into one worksheet
and
then Pears ( along with the 40 other cols which relate to apples or
pears)

184 apple
207 apple
208 apple
209 apple
184 Pears
207 Pears
208 Pears
209 Pears

At first i thought pivot table but as i have to do this twice a month
i thought VBA/marco - the previous person used to copy and paste and
i
think that just a waste of time.!!!


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA/Macro help


There are lots of way to do this. I sorted the original data and then move
the items with the same name to a new worksheet. The code assumes the sheet
names don't exist.


Sub splitdata()

With ActiveSheet

'sort data by colun D
LastRow = .Range("D" & Rows.Count).End(xlUp).Row
.Rows("1:" & LastRow).Sort _
header:=xlNo, _
key1:=.Range("D1"), _
order1:=xlAscending

RowCount = 1
StartRow = RowCount
Do While .Range("D" & RowCount) < ""
If .Range("D" & RowCount) < .Range("D" & (RowCount + 1)) Then
SheetName = .Range("D" & RowCount)
Set NewSht = Sheets.Add
NewSht.Name = SheetName
.Rows(StartRow & ":" & RowCount).Copy _
Destination:=NewSht.Rows(1)
StartRow = RowCount + 1
End If
RowCount = RowCount + 1
Loop
End With

End Sub


"WYMMIY" wrote:

All

I have a worksheet which has various col, what I would like to do is
to be able to create a new worksheet dependant on data in COL D so
for
example i would like to be able to split Apples into one worksheet
and
then Pears ( along with the 40 other cols which relate to apples or
pears)


184 apple
207 apple
208 apple
209 apple
184 Pears
207 Pears
208 Pears
209 Pears


At first i thought pivot table but as i have to do this twice a month
i thought VBA/marco - the previous person used to copy and paste and
i
think that just a waste of time.!!!



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
Macro to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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