PC Review


Reply
Thread Tools Rate Thread

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

 
 
New Member
Join Date: Jan 2008
Posts: 3
 
      19th Feb 2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and paste data between two workbooks shantanu Microsoft Excel Programming 1 27th Jan 2009 03:34 PM
how to copy and paste with the gridlines using excel =?Utf-8?B?c2Fz?= Microsoft Excel New Users 1 18th Oct 2006 12:41 AM
Re: Copy same range of data from all workbooks and paste into consolid Ron de Bruin Microsoft Excel Programming 7 18th Apr 2005 08:15 PM
Re: Copy same range of data from all workbooks and paste into consolid Doug Glancy Microsoft Excel Programming 0 12th Apr 2005 11:02 PM
Re: Copy same range of data from all workbooks and paste into consolid Macgru Microsoft Excel Programming 0 12th Apr 2005 10:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:11 AM.