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_Cl ick()
Unload Me
End Sub
------------------------------------------
Private Sub ClearButton_Cli ck()
Call UserForm_Initia lize
End Sub
---------------------------------------------
Private Sub OKButton_Click( )
'Determine Row
RowNumber = Me.TextBox1.Val ue
'copy the data
Sheets("Sheet1" ).Range("RowNum ber,1").Copy
Sheets("Sheet2" ).Range("B,1"). Paste
'Sheets("Sheet1 ").Range("RowNu mber,2").Copy
'Sheets("Sheet2 ").Range("B,2") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,3").Copy
'Sheets("Sheet2 ").Range("B,3") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,4").Copy
'Sheets("Sheet2 ").Range("C,3") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,5").Copy
'Sheets("Sheet2 ").Range("B,4") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,6").Copy
'Sheets("Sheet2 ").Range("B,5") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,7").Copy
'Sheets("Sheet2 ").Range("B,7") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,8").Copy
'Sheets("Sheet2 ").Range("C,9") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,9").Copy
'Sheets("Sheet2 ").Range("D,7") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,10").Copy
'Sheets("Sheet2 ").Range("C,7") .Paste
'Sheets("Sheet1 ").Range("RowNu mber,11").Copy
'Sheets("Sheet2 ").Range("D,12" ).Paste
'ThisWorkbook.S heets("Sheet1") .Cells("RowNumb er,1") = ThisWorkbook.Sh eets("Sheet2"). Cells("B,1")
'ThisWorkbook.S heets("Sheet1") .Cells("RowNumb er,2") = ThisWorkbook.Sh eets("Sheet2"). Cells("B,2")
'ThisWorkbook.S heets("Sheet1") .Cells("RowNumb er,3") = ThisWorkbook.Sh eets("Sheet2"). Cells("B,3")
'Sheets("Sheet2 ").Select
' Find the last row of data
'Sheets("Sheet2 ").Range("B1"). Select
'ActiveSheet.Pa ste
'Sheets("Sheet2 ").Select
End Sub
----------------------------------------------
Private Sub UserForm_Click( )
End Sub
----------------------------------------------
Private Sub UserForm_Initia lize()
TextBox1.Value = ""
End Sub
--------------------------------------------
1 902 ADezii 8,834
Recognized Expert Expert
This may not be the most effective approach, but it does work. - Dim strFrom As String
-
Dim intCtr As Integer
-
Dim shtFrom As Excel.Worksheet
-
Dim shtTo As Excel.Worksheet
-
-
Set shtFrom = ActiveWorkbook.Worksheets("Sheet1")
-
Set shtTo = ActiveWorkbook.Worksheets("Sheet2")
-
-
strFrom = InputBox$("Enter the From Row", "From Row")
-
-
If strFrom = "" Or Not IsNumeric(strFrom) Then Exit Sub
-
-
For intCtr = 1 To 11
-
Select Case intCtr
-
Case 1
-
shtTo.Range("B1") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 2
-
shtTo.Range("B2") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 3
-
shtTo.Range("B3") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 4
-
shtTo.Range("C3") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 5
-
shtTo.Range("B4") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 6
-
shtTo.Range("B5") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 7
-
shtTo.Range("B7") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 8
-
shtTo.Range("C9") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 9
-
shtTo.Range("D7") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 10
-
shtTo.Range("C7") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case 11
-
shtTo.Range("D12") = shtFrom.Cells(CLng(strFrom), intCtr).Value
-
Case Else
-
MsgBox shtFrom.Cells(CLng(strFrom), intCtr).Value
-
End Select
-
Next
Sign in to post your reply or Sign up for a free account.
Similar topics |
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)
Any help very much appreciated
Thanks
Ronny
Private Sub btnTargetAffGroupEmailImport_Click()
Dim MyXL As Object
|
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) columns called Weight,
Length and Diameter.
The table is bound to a DataGrid, and I am using the ItemDataBound
behavior to execute code that checks values in the table, e.g.:
public void OnDataBindValuesCheck (object sender,
DataGridItemEventArgs e)
|
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
|
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.
|
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 been searching for code for each part of the task separately and trying to piece together multiple macros, that do something similar, to what I’m trying to accomplish in my over all task, but I’m not having a lot of luck. So, here’s the entire task,...
| |
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 cell) on worksheet(1) and insert a row for the copied data above the named cell. In addition, each row on worksheet(2) must first be identified by a cell value in row (d) and be pasted to a corresponding named cell.
Source = Worksheet(2) ...
|
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.
|
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 subform2. Hope my Question is clear and not too stupid...
|
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.
|
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.
If any fastest way can i use to copy large table to another database.
I have use also use bcp utility as described in below url...but it will also take same large time.
http://csharpcode.org/sql-server-bulk-insert-from-one-table-to-another/
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |