Copy&Paste Data between workbooks: how to get gridlines back?

Joined
Jan 11, 2008
Messages
3
Reaction score
0
Hi, all!

I need to copy&paste data between workbooks, and that works fine. But my problem is that grid lines disappear in the cells where values are being copied into. Is there a way how I can avoid this?

The code below is "stuck" onto the UserForm:

Code:
Dim strSheet As String
Dim strKst As String
Dim lSpalte
Dim z, s, t
Dim WBQuelle, WBZiel As Workbook
Dim sFilename As String
Dim sQuelle As String
 
'input the sheet to copy into
strSheet = RefEdit1.Value
 
'and into which column
lSpalte = RefEdit2.Value
 
'open dialog to select the source workbook
sFilename = Application.GetOpenFilename
sQuelle = Right(sFilename, 23)
Workbooks.Open Filename:=sQuelle
 
Set WBQuelle = Workbooks(sQuelle)
Set WBZiel = Workbooks("Cost Center_VWL_2008.xls")
 
'determines last row and column
LetzteZeile = WBQuelle.Sheets("Tabelle1").Range("A1").SpecialCells(xlCellTypeLastCell).Row
LetzteSpalte = WBQuelle.Sheets("Tabelle1").Range("A1").SpecialCells(xlCellTypeLastCell).Column
LetzteZeile1 = WBZiel.Sheets(strSheet).Range("A1").SpecialCells(xlCellTypeLastCell).Row
 
 
If RefEdit2.Value = "j" Then
	lSpalte = 10
 
ElseIf RefEdit2.Value = "l" Then
	lSpalte = 12
 
ElseIf RefEdit2.Value = "af" Then
	lSpalte = 32
 
Else
	lSpalte = 34
 
End If
 
WBZiel.Activate
ActiveWorkbook.Sheets(strSheet).Activate
 
 
'search for the mathcing data
 
For s = 38 To 208
	For z = 5 To LetzteZeile
 
		For t = 2 To LetzteSpalte
 
			strKst = WBQuelle.Sheets("Tabelle1").Cells(4, t).Value
 
			If WBQuelle.Sheets("Tabelle1").Cells(z, 1).Value = WBZiel.Sheets(strSheet).Cells(s, 5).Value Then
 
				If strKst = strSheet Then
 
					'once data is found, copy and pste it:
					WBQuelle.Sheets("Tabelle1").Cells(z, t).Copy		 Destination:=WBZiel.Sheets(strSheet).Cells(s, lSpalte)
 
				End If
 
 
			 End If
 
		Next t
	Next z
Next s
 
'notify the user when import has terminated
MsgBox "Abgeschlossen!"

I'm using MS Excel 2003.

Thanks a lot in advance!!

Best,DummiestDummy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top