Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to add data to separate worksheets?


I'm a novice at VBA so I need a bit of help.
I have a worksheet (sheet 1) like this

Col A Col B
Sheet2 ABC
Sheet3 DEF
Sheet3 GHI
Sheet4 JKL

I want to add each row of this spreadsheet to the next blank row of the
worksheet specified in column A.
So if the worksheets are like this

Sheet 2 Sheet 3 Sheet 4
Col A Col A Col A
A C E
B CD

I want to end up like this:

Sheet 2 Sheet 3 Sheet 4
Col A Col A Col A
A C E
B CD JKL
ABC DEF
GHI

Also each time I run the macro the number of rows in Sheet 1 will vary
so I need to loop through sheet 1 until Col A is blank.

Can anyone show me how to do this?
Thanks


--
Special-K


------------------------------------------------------------------------
Special-K's Profile: http://www.excelforum.com/member.php...fo&userid=7470
View this thread: http://www.excelforum.com/showthread...hreadid=573666

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to add data to separate worksheets?

Hi Special-K,



--
---
Regards,
Norman



"Special-K" wrote
in message ...

I'm a novice at VBA so I need a bit of help.
I have a worksheet (sheet 1) like this

Col A Col B
Sheet2 ABC
Sheet3 DEF
Sheet3 GHI
Sheet4 JKL

I want to add each row of this spreadsheet to the next blank row of the
worksheet specified in column A.
So if the worksheets are like this

Sheet 2 Sheet 3 Sheet 4
Col A Col A Col A
A C E
B CD

I want to end up like this:

Sheet 2 Sheet 3 Sheet 4
Col A Col A Col A
A C E
B CD JKL
ABC DEF
GHI

Also each time I run the macro the number of rows in Sheet 1 will vary
so I need to loop through sheet 1 until Col A is blank.

Can anyone show me how to do this?
Thanks


--
Special-K


------------------------------------------------------------------------
Special-K's Profile:
http://www.excelforum.com/member.php...fo&userid=7470
View this thread: http://www.excelforum.com/showthread...hreadid=573666



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to add data to separate worksheets?

Hi Special-K.

Try something like:

'=============
Public Sub Tester001()
Dim WB As Workbook
Dim SH As Worksheet
Dim destSH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim destRng As Range

Set WB = Workbooks("YourBook.xls") '<<==== CHANGE

Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

Set rng = SH.Range("A1:A" & _
Cells(Rows.Count, "A").End(xlUp).Row)

For Each rCell In rng.Cells
With rCell
On Error Resume Next
Set destSH = Sheets(rCell.Value)
On Error GoTo 0

If Not destSH Is Nothing Then
Set destRng = _
destSH.Cells(Rows.Count, "A").End(xlUp)(2)
destRng.Value = .Offset(0, 1).Value
End If
End With
Next rCell
End Sub
'<<=============


---
Regards,
Norman


"Special-K" wrote
in message ...

I'm a novice at VBA so I need a bit of help.
I have a worksheet (sheet 1) like this

Col A Col B
Sheet2 ABC
Sheet3 DEF
Sheet3 GHI
Sheet4 JKL

I want to add each row of this spreadsheet to the next blank row of the
worksheet specified in column A.
So if the worksheets are like this

Sheet 2 Sheet 3 Sheet 4
Col A Col A Col A
A C E
B CD

I want to end up like this:

Sheet 2 Sheet 3 Sheet 4
Col A Col A Col A
A C E
B CD JKL
ABC DEF
GHI

Also each time I run the macro the number of rows in Sheet 1 will vary
so I need to loop through sheet 1 until Col A is blank.

Can anyone show me how to do this?
Thanks


--
Special-K


------------------------------------------------------------------------
Special-K's Profile:
http://www.excelforum.com/member.php...fo&userid=7470
View this thread: http://www.excelforum.com/showthread...hreadid=573666



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to add data to separate worksheets?

Hi Special-K,

Change:

Set rng = SH.Range("A1:A" & _
Cells(Rows.Count, "A").End(xlUp).Row)


to

Set rng = SH.Range("A1:A" & _
SH.Cells(Rows.Count, "A").End(xlUp).Row)


---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to add data to separate worksheets?


That's brilliant! Worked a treat!
Thanks Norma

--
Special-

-----------------------------------------------------------------------
Special-K's Profile: http://www.excelforum.com/member.php...nfo&userid=747
View this thread: http://www.excelforum.com/showthread.php?threadid=57366



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to add data to separate worksheets?


That's brilliant! Worked a treat!
Thanks Norma

--
Special-

-----------------------------------------------------------------------
Special-K's Profile: http://www.excelforum.com/member.php...nfo&userid=747
View this thread: http://www.excelforum.com/showthread.php?threadid=57366

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
Separate raw data onto different worksheets JN[_2_] Excel Worksheet Functions 4 April 6th 09 11:12 PM
... I want to chart data from 30 separate worksheets ... Dr. Darrell Excel Discussion (Misc queries) 1 September 14th 06 03:41 PM
Save 2 separate data imports in separate worksheets on the same ex Jay Excel Worksheet Functions 1 March 8th 06 01:31 PM
sorting data into separate worksheets mg_sv_r Excel Worksheet Functions 1 January 31st 06 12:13 PM
Compare data on 2 separate worksheets. Wayne Excel Worksheet Functions 3 July 10th 05 04:25 AM


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