LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Macro Problem Copy Data from sheet1 to 2 but into different cells

Wow, you guys are quality!

Many, many many many thanks! Been racking my brains (what little there
is..) for ages over this one! lol...

Cheers! The code worked a treat, and I changed it slightly and made it
do something else useful to me too!!

You star!

Thanks again
Sam


Nigel wrote:
For the selected cell(s) in a row you can extract the row number using
ActiveCell.Row
so your source rows can be dynamically changed as each row is selected.
You need to ensure the activesheet is MAIN and the row range is within the
limits; option in following code......

Sub CreateBillDoc()
Dim wsD As Worksheet, wsB As Worksheet, xARow As Long
Dim minRow As Long, maxRow As Long
Set wsD = Worksheets("MAIN")
Set wsB = Worksheets("Billing Statement")
' set upper and lower limits
minRow = 10
maxRow = 100

If ActiveSheet.Name = wsD.Name Then
xARow = ActiveCell.Row
If xARow = minRow And xARow <= maxRow Then
wsB.Range("B9") = wsD.Cells(xARow, "C")
wsB.Range("C9") = wsD.Cells(xARow, "D")
wsB.Range("B10") = wsD.Cells(xARow, "E")
wsB.Range("B14") = wsD.Cells(xARow, "F")
wsB.Range("A17") = wsD.Cells(xARow, "K")
wsB.Range("D17") = wsD.Cells(xARow, "L")
wsB.Range("F10") = wsD.Cells(xARow, "P")
Else
MsgBox "Selected a row within the range: " & minRow & " to " & maxRow
End If
Else
MsgBox "Please select the MAIN sheet before transferring data"
End If
End Sub


--
Cheers
Nigel



wrote in message
ups.com...
Hi all,

I'm a complete noobie at Excel VBA,,,

My problem is...

I have a spreadsheet and on page 1, named "MAIN"..

I want to be able to select a row, and have the cells copied to another
sheet

Copy the data from cells C4, D4, E4, F4, K4, L4 and P4..(from sheet
MAIN)

into sheet Billing Statement..

B9, C9, B10, B14, A17, D17, F10 Respectively...and the Cell numbers
increment by one as each row goes down...


The sheet for the data to be copied to is called Billing Statement...

Any help on this would be fantastic,,,been trying to figure it out for
ages..

I have about 100 lines, and would like to make one button that affects
which ever row is selected and copys the data from the above mentioned
cells to the ones mentioned afterwards..

Obvisously I'd rather not manually record over 100 different buttons,

Feel free to post here or mail me directly if you need more
information.

Thanks!


 
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 data from a list in sheet1 and paste into sheet2 Michael Excel Discussion (Misc queries) 3 April 23rd 08 06:52 PM
copy data from sheet1 to sheet but in varying positons Bossman7121 Excel Worksheet Functions 3 December 6th 07 02:04 PM
To copy data from Sheet2 to Sheet1 in Excel using VB.net [email protected] Excel Programming 0 July 21st 06 08:08 PM
Macro-Copy various cells in sheet1 into next available row in sheet 2 lunker55 Excel Discussion (Misc queries) 7 October 21st 05 11:05 PM
Copy Data (Sheet2 to Sheet1) Updates Web Query JStone0218 Excel Programming 0 October 9th 03 02:07 AM


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