Thread: keep formatting
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Striker Striker is offline
external usenet poster
 
Posts: 55
Default keep formatting

I am copying a large range, nealy 60K rows. One of the colums has a 15 digit
number in it. The destination cell is pre-formatted as text, and I want to
keep it that way. However when I copy the range from the CSV file to the
template, the formatting goes with it. Code below, how can I maintain the
formatting I have in the destination sheet?

Dim iLastRow As Long
Dim sFile1 As String
Dim wb, wkbkCSV As Workbook
Dim rDestCell As Range

sFile1 = Application.GetOpenFilename("CSV Files, *.csv")
If sFile1 = "False" Then
Exit Sub
End If

Set rDestCell = Workbooks("Sessions.xlsm").Worksheets("Sheet1").Ra nge("A2")
Set wkbkCSV = Workbooks.Open(Filename:=sFile1)

With wkbkCSV
.Worksheets(1).UsedRange.Copy Destination:=rDestCell
.Close savechanges:=False
End With