Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help with selection code

Hi All,

I am creating a workbook that has one main page that will have a customer
name and item to be delivered to the customer. the other worksheeets in the
workbook will be labled something like truck1 truck2, etc. The items on the
main pull sheet will be done at one time during the day and then later they
will be assigned a truck number. What I would like to do is put some code
on each truck worksheet on activate so that when someone goes to that
worksheet it will go to the main pull sheet and go thru and pull out all the
ones that have been assigned to that truck.
I am not real familiar with how to pull excel "recordsets", i know how to do
this working in visual basic but am not sure how to go thru an excel list.
The main pull list will vary in lenght each day so i know i need a looping
statement for i = 1 to ?. second question i am not sure is when it pull the
record to put on the worksheet i know that I want it to start on row 5 but
am not sure how to code it so that the next record and so forth fills in the
next line down.
Any help or website that i might look at would be great.

Thanks,


Jeff


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with selection code

There are several ways to do this, but
assumingthe truck name (matching the sheetname) is in column "C"

Private Sub Worksheet_Activate()
dim sh as worksheet, rng as range
Dim cell as Range
Dim rw as Long
set sh = worksheets("Main")
me.Rows("5:65536").Clearcontents
set rng = sh.range(sh.Cells(1,"C"),sh.Cells(rows.count,"C"). End(xlup))
rw = 5
for each cell in rng
if lcase(cell.Value) = lcase(me.name) then
cell.Entirerow.copy Destination:= _
sh.Cells(rw,1)
rw = rw + 1
end if
Next

End Sub

Right click on the sheet tab and select view code, then paste in code like
the above in the resulting module.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Hi All,

I am creating a workbook that has one main page that will have a customer
name and item to be delivered to the customer. the other worksheeets in

the
workbook will be labled something like truck1 truck2, etc. The items on

the
main pull sheet will be done at one time during the day and then later

they
will be assigned a truck number. What I would like to do is put some code
on each truck worksheet on activate so that when someone goes to that
worksheet it will go to the main pull sheet and go thru and pull out all

the
ones that have been assigned to that truck.
I am not real familiar with how to pull excel "recordsets", i know how to

do
this working in visual basic but am not sure how to go thru an excel list.
The main pull list will vary in lenght each day so i know i need a looping
statement for i = 1 to ?. second question i am not sure is when it pull

the
record to put on the worksheet i know that I want it to start on row 5 but
am not sure how to code it so that the next record and so forth fills in

the
next line down.
Any help or website that i might look at would be great.

Thanks,


Jeff




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help with selection code

Hi Tom,

The code is close but something is not quite right. When i go to Truck 1
worksheet it runs the code but what it is doing is replacing the items in my
Main pull list worksheet with the items for Truck 1. I am thinking it might
be because we first Set to Main or I am not setting the Destination right?

I am trying to debug and walk thru to see if i can figure it out. Any
Ideas?

Thanks,

Jeff
"Tom Ogilvy" wrote in message
...
There are several ways to do this, but
assumingthe truck name (matching the sheetname) is in column "C"

Private Sub Worksheet_Activate()
dim sh as worksheet, rng as range
Dim cell as Range
Dim rw as Long
set sh = worksheets("Main")
me.Rows("5:65536").Clearcontents
set rng = sh.range(sh.Cells(1,"C"),sh.Cells(rows.count,"C"). End(xlup))
rw = 5
for each cell in rng
if lcase(cell.Value) = lcase(me.name) then
cell.Entirerow.copy Destination:= _
sh.Cells(rw,1)
rw = rw + 1
end if
Next

End Sub

Right click on the sheet tab and select view code, then paste in code like
the above in the resulting module.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Hi All,

I am creating a workbook that has one main page that will have a

customer
name and item to be delivered to the customer. the other worksheeets in

the
workbook will be labled something like truck1 truck2, etc. The items on

the
main pull sheet will be done at one time during the day and then later

they
will be assigned a truck number. What I would like to do is put some

code
on each truck worksheet on activate so that when someone goes to that
worksheet it will go to the main pull sheet and go thru and pull out all

the
ones that have been assigned to that truck.
I am not real familiar with how to pull excel "recordsets", i know how

to
do
this working in visual basic but am not sure how to go thru an excel

list.
The main pull list will vary in lenght each day so i know i need a

looping
statement for i = 1 to ?. second question i am not sure is when it pull

the
record to put on the worksheet i know that I want it to start on row 5

but
am not sure how to code it so that the next record and so forth fills in

the
next line down.
Any help or website that i might look at would be great.

Thanks,


Jeff






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with selection code

sh.Cells(rw,1)
should be

me.cells(rw,1)


Private Sub Worksheet_Activate()
dim sh as worksheet, rng as range
Dim cell as Range
Dim rw as Long
set sh = worksheets("Main")
me.Rows("5:65536").Clearcontents
set rng = sh.range(sh.Cells(1,"C"),sh.Cells(rows.count,"C"). End(xlup))
rw = 5
for each cell in rng
if lcase(cell.Value) = lcase(me.name) then
cell.Entirerow.copy Destination:= _
me.Cells(rw,1)
rw = rw + 1
end if
Next

End Sub

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Hi Tom,

The code is close but something is not quite right. When i go to Truck 1
worksheet it runs the code but what it is doing is replacing the items in

my
Main pull list worksheet with the items for Truck 1. I am thinking it

might
be because we first Set to Main or I am not setting the Destination right?

I am trying to debug and walk thru to see if i can figure it out. Any
Ideas?

Thanks,

Jeff
"Tom Ogilvy" wrote in message
...
There are several ways to do this, but
assumingthe truck name (matching the sheetname) is in column "C"

Private Sub Worksheet_Activate()
dim sh as worksheet, rng as range
Dim cell as Range
Dim rw as Long
set sh = worksheets("Main")
me.Rows("5:65536").Clearcontents
set rng = sh.range(sh.Cells(1,"C"),sh.Cells(rows.count,"C"). End(xlup))
rw = 5
for each cell in rng
if lcase(cell.Value) = lcase(me.name) then
cell.Entirerow.copy Destination:= _
sh.Cells(rw,1)
rw = rw + 1
end if
Next

End Sub

Right click on the sheet tab and select view code, then paste in code

like
the above in the resulting module.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Hi All,

I am creating a workbook that has one main page that will have a

customer
name and item to be delivered to the customer. the other worksheeets

in
the
workbook will be labled something like truck1 truck2, etc. The items

on
the
main pull sheet will be done at one time during the day and then later

they
will be assigned a truck number. What I would like to do is put some

code
on each truck worksheet on activate so that when someone goes to that
worksheet it will go to the main pull sheet and go thru and pull out

all
the
ones that have been assigned to that truck.
I am not real familiar with how to pull excel "recordsets", i know how

to
do
this working in visual basic but am not sure how to go thru an excel

list.
The main pull list will vary in lenght each day so i know i need a

looping
statement for i = 1 to ?. second question i am not sure is when it

pull
the
record to put on the worksheet i know that I want it to start on row 5

but
am not sure how to code it so that the next record and so forth fills

in
the
next line down.
Any help or website that i might look at would be great.

Thanks,


Jeff








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help with selection code

Thanks Tom that did the trick, i was close on where the problem was i just
was not putting in the right syntax.

Thanks again for the help,

Jeff

"Tom Ogilvy" wrote in message
...
sh.Cells(rw,1)
should be

me.cells(rw,1)


Private Sub Worksheet_Activate()
dim sh as worksheet, rng as range
Dim cell as Range
Dim rw as Long
set sh = worksheets("Main")
me.Rows("5:65536").Clearcontents
set rng = sh.range(sh.Cells(1,"C"),sh.Cells(rows.count,"C"). End(xlup))
rw = 5
for each cell in rng
if lcase(cell.Value) = lcase(me.name) then
cell.Entirerow.copy Destination:= _
me.Cells(rw,1)
rw = rw + 1
end if
Next

End Sub

--
Regards,
Tom Ogilvy

"Jeff" wrote in message
...
Hi Tom,

The code is close but something is not quite right. When i go to Truck

1
worksheet it runs the code but what it is doing is replacing the items

in
my
Main pull list worksheet with the items for Truck 1. I am thinking it

might
be because we first Set to Main or I am not setting the Destination

right?

I am trying to debug and walk thru to see if i can figure it out. Any
Ideas?

Thanks,

Jeff
"Tom Ogilvy" wrote in message
...
There are several ways to do this, but
assumingthe truck name (matching the sheetname) is in column "C"

Private Sub Worksheet_Activate()
dim sh as worksheet, rng as range
Dim cell as Range
Dim rw as Long
set sh = worksheets("Main")
me.Rows("5:65536").Clearcontents
set rng = sh.range(sh.Cells(1,"C"),sh.Cells(rows.count,"C"). End(xlup))
rw = 5
for each cell in rng
if lcase(cell.Value) = lcase(me.name) then
cell.Entirerow.copy Destination:= _
sh.Cells(rw,1)
rw = rw + 1
end if
Next

End Sub

Right click on the sheet tab and select view code, then paste in code

like
the above in the resulting module.

--
Regards,
Tom Ogilvy



"Jeff" wrote in message
...
Hi All,

I am creating a workbook that has one main page that will have a

customer
name and item to be delivered to the customer. the other worksheeets

in
the
workbook will be labled something like truck1 truck2, etc. The

items
on
the
main pull sheet will be done at one time during the day and then

later
they
will be assigned a truck number. What I would like to do is put

some
code
on each truck worksheet on activate so that when someone goes to

that
worksheet it will go to the main pull sheet and go thru and pull out

all
the
ones that have been assigned to that truck.
I am not real familiar with how to pull excel "recordsets", i know

how
to
do
this working in visual basic but am not sure how to go thru an excel

list.
The main pull list will vary in lenght each day so i know i need a

looping
statement for i = 1 to ?. second question i am not sure is when it

pull
the
record to put on the worksheet i know that I want it to start on row

5
but
am not sure how to code it so that the next record and so forth

fills
in
the
next line down.
Any help or website that i might look at would be great.

Thanks,


Jeff










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
cell selection code NDBC Excel Discussion (Misc queries) 6 August 11th 09 06:39 AM
Cell selection code ToddG Excel Programming 2 September 22nd 04 09:26 PM
Need Code For Selection SMILE Excel Programming 3 August 10th 04 12:34 PM
Selection code sixfivebeastman Excel Programming 3 May 27th 04 08:54 PM
Print Selection in Code Donna Brooks Excel Programming 2 July 25th 03 04:35 PM


All times are GMT +1. The time now is 10:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"