Copy to specific location

tomasj

New Member
Joined
Nov 19, 2009
Messages
10
Hi! Need help with the following. Have two workbooks one (Avvik_databas.xls) is the "database" and avvikelse_rapport_fixa.xls/sheet 1. I extract data with vlookup from the "database file" (all values are from the same row) and paste the values in to avvikelse_rapport_fixa.xls/sheet1. I need to find the way back to the right row in the "database" and paste a new value in to one of the cells i that row. The reference for the row is the first value in that row this value was collected earlier.The "database" is normally closed. As a newbie any help would be appreciated. Thank you Tomas
 
Hi Andrew!
Thank you for your assistance. I amended your code and now it works fine.

Sub Copy_move()
Set SourceRange = ThisWorkbook.Sheets("Fyll i").Range("B13")
' Change the sheet name of the database workbook
Set DestWB = Workbooks.Open(ThisWorkbook.Path & "\avvik_databas.xls")
Set DestSh = DestWB.Worksheets("Blad1")
Lr = WorksheetFunction.Match(CDbl(ThisWorkbook.Sheets("Fyll i").Range("E1").Value), DestSh.Columns(1), False)
Set DestRange = DestSh.Range("K" & Lr)
DestRange.Value = SourceRange.Value
'We make DestRange the same size as SourceRange and use the Value
'property to give DestRange the same values
With SourceRange

Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value

DestWB.Close Savechanges:=True

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
' Copy_move Makro
' Korrigerande

TomasJ
:)
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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