Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default compiling data from one book to another...too many "ifs"

I made a spreadsheet a couple of years ago and it took forever. I need
something similar and I'm determined to find an easier way!

I have rows of data in Book1. I would like to pull certain columns of
data from these rows and add them up in a neat TOTALS grid in Book2,
with a condition.

For instance, this is my general set up:
Book1
ColumnA: Name (salesperson)
ColumnB: number (units)
ColumnC: number (volume)
ColumnD: (either blank or an "x")

Each row has different names and associated data in the appropriate
columns. I'd like to pull each salesperson's units and volume into
Book2, depending on whether there is an X in Column D (No X = don't
pull over any data from that row; X = pull data over)

So I can write a million IF statements or there is an easier way I'm
hoping someone can point out for me. (And perhaps instead of text "x's"
i could use a button or pivot table or something??)

I hope I've explained what I'm trying to do well enough...if not please
let me know. Thank-you, in advance, for any help you can provide!

Jacob

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default compiling data from one book to another...too many "ifs"

Test this macro on copies of the source and destination workbooks first. The
macro is designed to be run from the destination wb and to select and open
the source wb using a dialog called by the macro. Minimal testing.

Whe
1. wb1 = destination workbook.
2. wb2 = source workbook.
3. wks1 = destination worksheet.
4. wks2 = source worksheet.
5. Destination worksheet name = "Current Sales Data".
6. Source worksheet name = "Sales Data".
7. First destination cell is cell A2 (A1 assumed to be a header).
8. First source cell is cell A2 also.
9. There is assumed to be no gaps in the source "Sales Person" data else the
macro will stop at the gap.

Sub TransferSalesData()
Dim wb1 As Workbook, wb2 As Workbook
Dim wks1 As Worksheet, wks2 As Worksheet
Dim r As Range, c As Range, cc As Range
Dim FNm As Variant

Set wb1 = ActiveWorkbook
Set wks1 = wb1.Sheets("Current Sales Data")
Set c = wks1.Range("A2")
FNm = Application.GetOpenFilename("Excel files(*.xls), *.xls", _
Title:="Transfer Sales Data")
If VarType(FNm) = vbBoolean Then Exit Sub
Application.ScreenUpdating = False
Set wb2 = Workbooks.Open(FNm)
Set wks2 = wb2.Sheets("Sales Data")
wb1.Activate
Set r = wks2.Range(wks2.Range("A2"), wks2.Range("A2").End(xlDown))
For Each cc In r.Cells
If Trim(UCase(cc(1, 4))) = "X" Then
c.Resize(1, 3).Value = cc.Resize(1, 3).Value
Set c = c(2)
End If
Next
Application.ScreenUpdating = True
End Sub

Regards,
Greg


"jacob" wrote:

I made a spreadsheet a couple of years ago and it took forever. I need
something similar and I'm determined to find an easier way!

I have rows of data in Book1. I would like to pull certain columns of
data from these rows and add them up in a neat TOTALS grid in Book2,
with a condition.

For instance, this is my general set up:
Book1
ColumnA: Name (salesperson)
ColumnB: number (units)
ColumnC: number (volume)
ColumnD: (either blank or an "x")

Each row has different names and associated data in the appropriate
columns. I'd like to pull each salesperson's units and volume into
Book2, depending on whether there is an X in Column D (No X = don't
pull over any data from that row; X = pull data over)

So I can write a million IF statements or there is an easier way I'm
hoping someone can point out for me. (And perhaps instead of text "x's"
i could use a button or pivot table or something??)

I hope I've explained what I'm trying to do well enough...if not please
let me know. Thank-you, in advance, for any help you can provide!

Jacob


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default compiling data from one book to another...too many "ifs"

Did you try DataFilterautomatic Filter or Elaborate Filter.

This should help

--
AP

"jacob" a écrit dans le message de
oups.com...
I made a spreadsheet a couple of years ago and it took forever. I need
something similar and I'm determined to find an easier way!

I have rows of data in Book1. I would like to pull certain columns of
data from these rows and add them up in a neat TOTALS grid in Book2,
with a condition.

For instance, this is my general set up:
Book1
ColumnA: Name (salesperson)
ColumnB: number (units)
ColumnC: number (volume)
ColumnD: (either blank or an "x")

Each row has different names and associated data in the appropriate
columns. I'd like to pull each salesperson's units and volume into
Book2, depending on whether there is an X in Column D (No X = don't
pull over any data from that row; X = pull data over)

So I can write a million IF statements or there is an easier way I'm
hoping someone can point out for me. (And perhaps instead of text "x's"
i could use a button or pivot table or something??)

I hope I've explained what I'm trying to do well enough...if not please
let me know. Thank-you, in advance, for any help you can provide!

Jacob



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default compiling data from one book to another...too many "ifs"

Creating a pivot table would do it all in one step and should be exactly
what you want.

See Debra Dalgleish's pages on Pivot Table if you are not familiar with them

http://www.contextures.com/tiptech.html

see pivot tables in the index.

--
Regards,
Tom Ogilvy

"jacob" wrote in message
oups.com...
I made a spreadsheet a couple of years ago and it took forever. I need
something similar and I'm determined to find an easier way!

I have rows of data in Book1. I would like to pull certain columns of
data from these rows and add them up in a neat TOTALS grid in Book2,
with a condition.

For instance, this is my general set up:
Book1
ColumnA: Name (salesperson)
ColumnB: number (units)
ColumnC: number (volume)
ColumnD: (either blank or an "x")

Each row has different names and associated data in the appropriate
columns. I'd like to pull each salesperson's units and volume into
Book2, depending on whether there is an X in Column D (No X = don't
pull over any data from that row; X = pull data over)

So I can write a million IF statements or there is an easier way I'm
hoping someone can point out for me. (And perhaps instead of text "x's"
i could use a button or pivot table or something??)

I hope I've explained what I'm trying to do well enough...if not please
let me know. Thank-you, in advance, for any help you can provide!

Jacob



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default compiling data from one book to another...too many "ifs"

jacob,

It sounds like a good situation for a pivot table.

hth,

Doug


"jacob" wrote in message
oups.com...
I made a spreadsheet a couple of years ago and it took forever. I need
something similar and I'm determined to find an easier way!

I have rows of data in Book1. I would like to pull certain columns of
data from these rows and add them up in a neat TOTALS grid in Book2,
with a condition.

For instance, this is my general set up:
Book1
ColumnA: Name (salesperson)
ColumnB: number (units)
ColumnC: number (volume)
ColumnD: (either blank or an "x")

Each row has different names and associated data in the appropriate
columns. I'd like to pull each salesperson's units and volume into
Book2, depending on whether there is an X in Column D (No X = don't
pull over any data from that row; X = pull data over)

So I can write a million IF statements or there is an easier way I'm
hoping someone can point out for me. (And perhaps instead of text "x's"
i could use a button or pivot table or something??)

I hope I've explained what I'm trying to do well enough...if not please
let me know. Thank-you, in advance, for any help you can provide!

Jacob





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default compiling data from one book to another...too many "ifs"

All:

I have no idea how to create a pivot table. I would need a working
example or somethign to show me how. I'm good with forumulas,
formatting, etc., but have just never done a pivot table before.

Would anyone be able to show me how? And I could send you the excel
spreadsheet for you to take a look at what i'm trying to do. The
website above only helps specific pivot table questions, not creating
one from scratch.

Stuck,

Jacob



Doug Glancy wrote:
jacob,

It sounds like a good situation for a pivot table.

hth,

Doug


"jacob" wrote in message
oups.com...
I made a spreadsheet a couple of years ago and it took forever. I need
something similar and I'm determined to find an easier way!

I have rows of data in Book1. I would like to pull certain columns of
data from these rows and add them up in a neat TOTALS grid in Book2,
with a condition.

For instance, this is my general set up:
Book1
ColumnA: Name (salesperson)
ColumnB: number (units)
ColumnC: number (volume)
ColumnD: (either blank or an "x")

Each row has different names and associated data in the appropriate
columns. I'd like to pull each salesperson's units and volume into
Book2, depending on whether there is an X in Column D (No X = don't
pull over any data from that row; X = pull data over)

So I can write a million IF statements or there is an easier way I'm
hoping someone can point out for me. (And perhaps instead of text "x's"
i could use a button or pivot table or something??)

I hope I've explained what I'm trying to do well enough...if not please
let me know. Thank-you, in advance, for any help you can provide!

Jacob


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default compiling data from one book to another...too many "ifs"

Jacob,

I'm not that great with them myself, but I do find the wizard gets me a good
start.

hth,

Doug


"jacob" wrote in message
oups.com...
All:

I have no idea how to create a pivot table. I would need a working
example or somethign to show me how. I'm good with forumulas,
formatting, etc., but have just never done a pivot table before.

Would anyone be able to show me how? And I could send you the excel
spreadsheet for you to take a look at what i'm trying to do. The
website above only helps specific pivot table questions, not creating
one from scratch.

Stuck,

Jacob



Doug Glancy wrote:
jacob,

It sounds like a good situation for a pivot table.

hth,

Doug


"jacob" wrote in message
oups.com...
I made a spreadsheet a couple of years ago and it took forever. I need
something similar and I'm determined to find an easier way!

I have rows of data in Book1. I would like to pull certain columns of
data from these rows and add them up in a neat TOTALS grid in Book2,
with a condition.

For instance, this is my general set up:
Book1
ColumnA: Name (salesperson)
ColumnB: number (units)
ColumnC: number (volume)
ColumnD: (either blank or an "x")

Each row has different names and associated data in the appropriate
columns. I'd like to pull each salesperson's units and volume into
Book2, depending on whether there is an X in Column D (No X = don't
pull over any data from that row; X = pull data over)

So I can write a million IF statements or there is an easier way I'm
hoping someone can point out for me. (And perhaps instead of text "x's"
i could use a button or pivot table or something??)

I hope I've explained what I'm trying to do well enough...if not please
let me know. Thank-you, in advance, for any help you can provide!

Jacob




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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
error while compiling "OBJECT REQUIRED" nuti Excel Discussion (Misc queries) 1 January 12th 06 03:14 PM
Problem in compiling code containing "$" char Alain79[_3_] Excel Programming 11 June 30th 05 10:07 AM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


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