I want to copy a range of cells from one sheet to an other sheet.
Why is this not working?
Kind regardsSheets("Map1").Range(Cells(5, 5), Cells(10, 5)).Copy _
Destination:=Sheets("Map2").Range(Cells(5, 5))
Jan (John)
I want to copy a range of cells from one sheet to an other sheet.
Why is this not working?
Kind regardsSheets("Map1").Range(Cells(5, 5), Cells(10, 5)).Copy _
Destination:=Sheets("Map2").Range(Cells(5, 5))
Jan (John)
Because mostlikely Map2 is anohter workbook and not another sheet as (in dutch) sheetnames are Blad1 and Blad2 where map1 and map2 are default indication of different workbooks.
so unless yours sheets are called map1 and map2 and are within the same workbook it will not work.
Try to specify the worksheets
Please Login or Register to view this content.
< ----- Please click the little star * next to add reputation if my post helps you
Visit Forum : From Here
Dear YasserKhalli
It works! Thanks a lot.
I have still one question: How do I (horizontal)center the data in the sh worksheet?
Kind regards
Jan
PS. I managed already.
Tread can be colosed
Last edited by Jan Lichtenbelt; 02-21-2019 at 12:12 PM.
You can simply record a macro to get the lines of aligning to center. Try it. It is so easy
I hve still one problem, which I do not understand. I have the following subroputine for alignment of a column "Id" in sheet "Blad2".
If I use this subroutine in the module (F5), it works perfectly. However, if I call this subroutine as results of the action on pushing a active button (part of sheet "Blad1") it fails. I get errornumber 9, something like "Subcript out of range".Sub TestAlignment()
Dim wsTo As Worksheet
Dim HeaderTo As String
Dim SheetNameTo As String
Dim Alignment As Integer
On Error GoTo Fout
HeaderTo = "Id"
SheetNameTo = "Blad2"
Alignment = 0
Set wsTo = ThisWorkbook.Worksheets(SheetNameTo)
'The range marked as "Id" is a single cell in sheet Blad2
wsTo.Range(HeaderTo).Select
Select Case Alignment
Case 0
Range(Selection, Selection.End(xlDown)).HorizontalAlignment = xlLeft
Case 1
Range(Selection, Selection.End(xlDown)).HorizontalAlignment = xlCenter
Case 2
Range(Selection, Selection.End(xlDown)).HorizontalAlignment = xlRight
Case Else
End Select
Exit Sub
Fout:
MsgBox Err.Number & " " & Err.Description
End Sub
Why the different behavoir? What can I do that the subroutine works in both cases.
Kind regards
Jan (John)
I make the problem more readable (I hope), I made a Excel file which shows the problem more clear. I hope someone can help me.
Kind regards
Jan
NO one can help?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks