Move Only The Selected Data From 1 WorkBook sheet1 to Another Already Created WorkBook Sheet1

xcruc1at3r

Board Regular
Joined
Aug 4, 2011
Messages
50
Can any one Kindly Plssss...Modify this Coding To The Selected Data From 1 WorkBook's Sheet1 To Another Already Created WorkBook's Sheet1 in My documents.
Will Appreciate the HELP

Sub CopySelectedMulti()
Dim NextRow&, rng As Range
With Sheets("Sheet2")
For Each rng In Selection.Areas
On Error Resume Next
NextRow = .Cells.Find(What:="*", After:=.Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
If Err <> 0 Then NextRow = 1
On Error GoTo 0
rng.Copy .Cells(NextRow, 1)
Next rng
End With
End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
what is the logic of selection in sheet1 book1

is the selection contiguous
or not contiguous.

suggest post small extract of sheet1 book1

where do you want to copy in sheet1 book2,
 
Upvote 0
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> his coding is showing error with End Sub i am not able to understand why due to what reason its showing Error at END SUB when i run it.... even dough it transfers the data but shows errors Not the Ending Message....


Code:
Sub MoveStuff()
  Dim sourceBook As Workbook
  Dim targetBook As Workbook
  Dim targetPath As String
  'make easy reference names for both the book data is coming FROM and going TO
  Set sourceBook = ActiveWorkbook
  'set the target workbook's filepath as a variable so it is easy to change later
  targetPath = "C:\Documents and Settings\mintezar\My Documents\Archives\Sample\ITV PROJECT\Transfer of Selected Data to Main Database\DATABASE.xls"
  'copy the selected range
  Selection.Copy
  'open the target book
  Workbooks.Open targetPath, Format:=2
  'make easy reference names for both the book data is coming FROM and going TO
  Set targetBook = ActiveWorkbook
  'paste info into A1 on sheet 1
  targetBook.Sheets(1).Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial.Active
  ActiveSheet.Paste
  targetBook.Activate
  MsgBox "Data transfer complete.", vbInformation, "Process Complete"
  End Sub
 
Upvote 0
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> his coding is showing error with End Sub i am not able to understand why due to what reason its showing Error at END SUB when i run it.... even dough it transfers the data but shows errors Not the Ending Message....


Code:
Sub MoveStuff()
  Dim sourceBook As Workbook
  Dim targetBook As Workbook
  Dim targetPath As String
  'make easy reference names for both the book data is coming FROM and going TO
  Set sourceBook = ActiveWorkbook
  'set the target workbook's filepath as a variable so it is easy to change later
  targetPath = <!--[if gte mso 9]><xml>  <w:WordDocument>   <w:View>Normal</w:View>   <w:Zoom>0</w:Zoom>   <w:PunctuationKerning/>   <w:ValidateAgainstSchemas/>   <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>   <w:IgnoreMixedContent>false</w:IgnoreMixedContent>   <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>   <w:Compatibility>    <w:BreakWrappedTables/>    <w:SnapToGridInCell/>    <w:WrapTextWithPunct/>    <w:UseAsianBreakRules/>    <w:DontGrowAutofit/>   </w:Compatibility>   <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>  </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml>  <w:LatentStyles DefLockedState="false" LatentStyleCount="156">  </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style>  /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} </style> <![endif]-->[FONT=&quot]“\\siggen01\longworth$\insurance sheet.xlsx”[/FONT]
  'copy the selected range
  Selection.Copy
  'open the target book
  Workbooks.Open targetPath, Format:=2
  'make easy reference names for both the book data is coming FROM and going TO
  Set targetBook = ActiveWorkbook
  'paste info into A1 on sheet 1
  targetBook.Sheets(1).Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial.Active
  ActiveSheet.Paste
  targetBook.Activate
  MsgBox "Data transfer complete.", vbInformation, "Process Complete"
  End Sub
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,548
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top