Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dynamically select sheet

A cell in each row of my "main" spreadsheet (DataEntry) has the name of other
spreadsheets (in the same workbook). For simplicity, assume there are 4
spreadsheets -- named A, B, C, and D.

As a macro loops through the DataEntry rows, it is to copy each row to the
appropriate spreadsheet (A, B, C, or D) based on the sheet name in, say,
column D of each row (of DataEntry).

Using Sheets(?????).Select (if that's what I should use), what is the
syntax for referring to Column D and the respective row? I've tried
Sheets("D" & x).Select . which results in a 'bug'.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default dynamically select sheet


Assuming datarange is column A and starts at A2 with no blank rows

dim dest as range
dim datarg as range
dim rcell as range
dim rgend as range
dim cpyrg as range

set rgend = Worksheets("DataEntry).range("a2").end(xldown)

set datarg = Worksheets("DataEntry).range("a2:a" & rgend.row).

for each rcell in datarg
set cpryrg = range(rcell,rcell.offset(0,3))
cpyrg.copy
' this copies the first three columns of the current row
set dest =
worksheets(cell.offset(0,4).value).range("a65000") .end(xlup).offset(1,0)
' this denotes the first blank row on the worksheet named in column
D
dest.pastespecial
next

HTH


swtrader wrote:
A cell in each row of my "main" spreadsheet (DataEntry) has the name of other
spreadsheets (in the same workbook). For simplicity, assume there are 4
spreadsheets -- named A, B, C, and D.

As a macro loops through the DataEntry rows, it is to copy each row to the
appropriate spreadsheet (A, B, C, or D) based on the sheet name in, say,
column D of each row (of DataEntry).

Using Sheets(?????).Select (if that's what I should use), what is the
syntax for referring to Column D and the respective row? I've tried
Sheets("D" & x).Select . which results in a 'bug'.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default dynamically select sheet

I noticed a typo in my code
this line

worksheets(cell.offset(0,4).value).range("a65000") .end(xlup).offset(1,0)
should be

worksheets(rcell.offset(0,4).value).range("a65000" ).end(xlup).offset(1,0)





bobbo wrote:
Assuming datarange is column A and starts at A2 with no blank rows

dim dest as range
dim datarg as range
dim rcell as range
dim rgend as range
dim cpyrg as range

set rgend = Worksheets("DataEntry).range("a2").end(xldown)

set datarg = Worksheets("DataEntry).range("a2:a" & rgend.row).

for each rcell in datarg
set cpryrg = range(rcell,rcell.offset(0,3))
cpyrg.copy
' this copies the first three columns of the current row
set dest =
worksheets(cell.offset(0,4).value).range("a65000") .end(xlup).offset(1,0)
' this denotes the first blank row on the worksheet named in column
D
dest.pastespecial
next

HTH


swtrader wrote:
A cell in each row of my "main" spreadsheet (DataEntry) has the name of other
spreadsheets (in the same workbook). For simplicity, assume there are 4
spreadsheets -- named A, B, C, and D.

As a macro loops through the DataEntry rows, it is to copy each row to the
appropriate spreadsheet (A, B, C, or D) based on the sheet name in, say,
column D of each row (of DataEntry).

Using Sheets(?????).Select (if that's what I should use), what is the
syntax for referring to Column D and the respective row? I've tried
Sheets("D" & x).Select . which results in a 'bug'.


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
dynamically select a range of cells for use in a formula isofuncurves Excel Worksheet Functions 1 February 2nd 06 01:34 AM
Transfer/Copy Sheet, Dynamically linked Sheet 0-0 Wai Wai ^-^ Excel Discussion (Misc queries) 2 December 23rd 05 10:04 PM
How to dynamically select a validation list from data in a cell? sessc Excel Discussion (Misc queries) 1 July 28th 05 06:11 PM
Dynamically select a Printer Bill Agee Excel Programming 2 November 4th 04 02:03 PM
how to select cells dynamically in excel macro? Excel user Excel Programming 1 November 1st 04 05:28 PM


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