1. Problem
ich stehe vor folgendem Problem.
Ich habe zwei Excelfiles geöffnet und möchte diese gerne auf meinem primären Bildschirm "splitten". Also das eine File auf der Linken und das andere File auf der rechten Seite.
Mein Code bis jetzt:
Hier erfahre ich die Größe des Bildschrims (soll nicht nur auf meinem PC laufen):
Workbooks("test.xlsm").Activate
Workbooks("test.xlsm").Application.WindowState = xlNormal
Workbooks("testl.xlsm").Application.WindowState = xlMaximized
Sheet22.Cells(1, 1) = Workbooks("test.xlsm").Application.Width
Sheet22.Cells(1, 2) = Workbooks("test.xlsm").Application.Height
und hier richte ich die files ein:
Function Resize(reli, workbookname)
If reli = "links" Then
Workbooks(workbookname).Activate
Workbooks(workbookname).Application.WindowState = xlNormal
Workbooks(workbookname).Application.Width = Sheet22.Cells(1, 1) / 2
Workbooks(workbookname).Application.Height = Sheet22.Cells(1, 2)
Workbooks(workbookname).Application.Top = -5.4
Workbooks(workbookname).Application.Left = Sheet22.Cells(1, 3)
End If
If reli = "rechts" Then
Workbooks(workbookname).Activate
Workbooks(workbookname).Application.WindowState = xlMaximized
Workbooks(workbookname).Application.WindowState = xlNormal
Workbooks(workbookname).Application.Width = Sheet22.Cells(1, 1) / 2
Workbooks(workbookname).Application.Height = Sheet22.Cells(1, 2)
Workbooks(workbookname).Application.Top = -5.4
Workbooks(workbookname).Application.Left = Sheet22.Cells(1, 1) / 2 + Sheet22.Cells(1, 3)
End If
End Function
Problem: die Files sind nicht genau in der Mitte, warum?
Zweite Frage:
Wenn ich dann beide Files nebeneinander habe möchte ich verschiedene Spaltennamen aus dem einen ins andere übertragen.
Z.B: Wenn Spalte1 in File(a) angewählt ist, dann soll ich file(b) in cells(1,1) der Buchstabe der Spalte stehen.
Wollte über selection.column=1 then cells(1,1)="a" gehen aber functioniert nicht, da ich das Workbook und den Sheetnamen nicht einfügen kann.
der folgende ansatz funktioniert leider auch nicht.
If Workbooks(fn).Sheets("Sheet1").Range("A:A").Select = True Then Sheet22.Cells(zeile, 4) = "a"
Danke für eure Hilfe!
Gruß