473,513 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How To Copy a Row of information to individual cells on another sheet

1 New Member
I am trying to copy a row of information from one sheet to different selected cells on another sheet using a command button that allows you to specify which row you want to copy from and paste that information onto another sheet in specific cells. This is what I have so far, as you can see I have tried several different methods however nothing is working so far.

Private Sub CancelButton_Click()

Unload Me

End Sub
------------------------------------------
Private Sub ClearButton_Click()

Call UserForm_Initialize

End Sub
---------------------------------------------
Private Sub OKButton_Click()

'Determine Row
RowNumber = Me.TextBox1.Value

'copy the data

Sheets("Sheet1").Range("RowNumber,1").Copy
Sheets("Sheet2").Range("B,1").Paste
'Sheets("Sheet1").Range("RowNumber,2").Copy
'Sheets("Sheet2").Range("B,2").Paste
'Sheets("Sheet1").Range("RowNumber,3").Copy
'Sheets("Sheet2").Range("B,3").Paste
'Sheets("Sheet1").Range("RowNumber,4").Copy
'Sheets("Sheet2").Range("C,3").Paste
'Sheets("Sheet1").Range("RowNumber,5").Copy
'Sheets("Sheet2").Range("B,4").Paste
'Sheets("Sheet1").Range("RowNumber,6").Copy
'Sheets("Sheet2").Range("B,5").Paste
'Sheets("Sheet1").Range("RowNumber,7").Copy
'Sheets("Sheet2").Range("B,7").Paste
'Sheets("Sheet1").Range("RowNumber,8").Copy
'Sheets("Sheet2").Range("C,9").Paste
'Sheets("Sheet1").Range("RowNumber,9").Copy
'Sheets("Sheet2").Range("D,7").Paste
'Sheets("Sheet1").Range("RowNumber,10").Copy
'Sheets("Sheet2").Range("C,7").Paste
'Sheets("Sheet1").Range("RowNumber,11").Copy
'Sheets("Sheet2").Range("D,12").Paste


'ThisWorkbook.Sheets("Sheet1").Cells("RowNumber,1" ) = ThisWorkbook.Sheets("Sheet2").Cells("B,1")
'ThisWorkbook.Sheets("Sheet1").Cells("RowNumber,2" ) = ThisWorkbook.Sheets("Sheet2").Cells("B,2")
'ThisWorkbook.Sheets("Sheet1").Cells("RowNumber,3" ) = ThisWorkbook.Sheets("Sheet2").Cells("B,3")


'Sheets("Sheet2").Select
' Find the last row of data
'Sheets("Sheet2").Range("B1").Select
'ActiveSheet.Paste
'Sheets("Sheet2").Select

End Sub
----------------------------------------------
Private Sub UserForm_Click()

End Sub
----------------------------------------------
Private Sub UserForm_Initialize()

TextBox1.Value = ""

End Sub
--------------------------------------------
Oct 27 '16 #1
1 896
ADezii
8,834 Recognized Expert Expert
This may not be the most effective approach, but it does work.
Expand|Select|Wrap|Line Numbers
  1. Dim strFrom As String
  2. Dim intCtr As Integer
  3. Dim shtFrom As Excel.Worksheet
  4. Dim shtTo As Excel.Worksheet
  5.  
  6. Set shtFrom = ActiveWorkbook.Worksheets("Sheet1")
  7. Set shtTo = ActiveWorkbook.Worksheets("Sheet2")
  8.  
  9. strFrom = InputBox$("Enter the From Row", "From Row")
  10.  
  11. If strFrom = "" Or Not IsNumeric(strFrom) Then Exit Sub
  12.  
  13. For intCtr = 1 To 11
  14.   Select Case intCtr
  15.     Case 1
  16.       shtTo.Range("B1") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  17.     Case 2
  18.       shtTo.Range("B2") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  19.     Case 3
  20.       shtTo.Range("B3") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  21.     Case 4
  22.       shtTo.Range("C3") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  23.     Case 5
  24.       shtTo.Range("B4") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  25.     Case 6
  26.       shtTo.Range("B5") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  27.     Case 7
  28.       shtTo.Range("B7") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  29.     Case 8
  30.       shtTo.Range("C9") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  31.     Case 9
  32.       shtTo.Range("D7") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  33.     Case 10
  34.       shtTo.Range("C7") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  35.     Case 11
  36.       shtTo.Range("D12") = shtFrom.Cells(CLng(strFrom), intCtr).Value
  37.     Case Else
  38.   MsgBox shtFrom.Cells(CLng(strFrom), intCtr).Value
  39.   End Select
  40. Next
Oct 27 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
633
by: Ronny Sigo | last post by:
Hello all, Could anybody help me referencing individual cells in excel? I don't know what I do wrong here (but I'm not familiar with excel vba) (Microsoft Excel 10.0 Object library is referenced)...
2
7305
by: jacqueharper | last post by:
I need to change the formatting of individual cells in a datagrid. I cannot figure out how to address individual cells by their column name. I have a DataTable which contains (for instance)...
3
9377
by: Christopher Lusardi | last post by:
If I want to copy one file to another how do I do that? I want to do this even if the second file already exists. Thanks, Christopher Lusardi
0
1005
by: rohithcs | last post by:
Hi, I have requirement where i need to copy group of cells in the spreadsheet or excel sheet and paste in Mail. Can anybody help me in this? I am new to VB, kindly help me out.
0
3175
by: Taxman | last post by:
Windows XP, MS Office Excel 2003 If the tasks, I’m trying accomplish have been addressed previously (separately or in combination). Please, provide the links or keyword search to find them. I’ve...
4
4007
by: JDVOIGT | last post by:
I am building a P&L on worksheet(1) based on data from worksheet(2). I need to copy rows of data from worksheet(2) and paste onto worksheet(1). The pasting process needs to find a named range (one...
3
12062
by: saums | last post by:
I want to change borderstyle of individual cells in datagridview for my current project.i found examples on 'AdjustCellBorderStyle' function on MSDN but couldn't use it.I need some help.
3
1422
by: Kappucino XL | last post by:
Hey There... I have two datasheet subforms, on a mainform: Subform1 and subform2. They receive their info from two separate tables. Now, I need to copy information from subform1 to a field in...
1
1777
by: sushmanibrad | last post by:
I just want to copy the data with format from one of my excel sheet to another sheet. currently i am doing in a same way but it only copying the data but not the format in which the data is located.
0
2061
by: pka246 | last post by:
I have sql server database and i contains about 4 crore plus records. When i am copy this table into another database using SQL Server Import/Export wizard it takes 1 hours per 10 lakh records. ...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.