473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Opening an excel file in an existing excel + copying formats

I wrote a macro for opening an excel file in an existing excel. But i cant copying the formats.

Can anyone help me, how can i copy the formats? i guess, it's easy, but i can't do it.

It's really important:)


Expand|Select|Wrap|Line Numbers
  1. Sub Megnyit()
  2.  
  3. Dim mf1 As Workbook
  4. Dim mf2 As Workbook
  5. Dim mlap As Worksheet
  6. Dim PasteStart As Range
  7.  
  8.  
  9. Set mf1 = ActiveWorkbook
  10. Set PasteStart = [1!A1]
  11.  
  12. Sheets("1").Select
  13.     Cells.Select
  14.     Selection.ClearContents
  15.  
  16.  
  17.  
  18. FileToOpen = Application.GetOpenFilename _
  19. (Title:="Please choose a Report to Parse", _
  20. FileFilter:="Report Files *.xls (*.xls),")
  21.  
  22. If FileToOpen = False Then
  23.     MsgBox "Nincs fájl kiválasztva!", vbExclamation, "ERROR"
  24.     Exit Sub
  25. Else
  26.     Set mf2 = Workbooks.Open(Filename:=FileToOpen)
  27.  
  28.     For Each mlap In mf2.Sheets
  29.       With mlap.UsedRange
  30.             .Copy PasteStart
  31.             Set PasteStart = PasteStart.Offset(.Rows.Count)
  32.  
  33.         End With
  34.     Next mlap
  35.  
  36. End If
  37.  
  38.     mf2.Close
  39.  
  40. End Sub
Aug 10 '15 #1
0 1054

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lisa | last post by:
I have an excel file on my server, which contains an embedded query. I want to be able to open the excel file, pass the contents of my variable into a cell within the worksheet and then refresh the...
3
by: g_mx6 | last post by:
I am not sure what I am doing wrong. I am trying to open a DSNLess connection and retrieve the data in an Excel sheet using ASP. Shouldnt be this complicated but I've been trying to get this to...
4
by: Vishal | last post by:
Hello, I have a dataset with some content. I can convert this dataset in a csv format which is then stored in a stringwriter. Now I want this be open via excel, so I set the contenttype...
4
by: Mark | last post by:
Hello - I receive the error message: System.Runtime.InteropServices.COMException: The remote procedure call failed. when I open an Excel file using from an ASP.Net page. Imports...
2
by: PJ6 | last post by:
This little snippet works for .txt files, but for any .xls file I get a file not found error, even though the file is really there. Yes, I checked to see if the path is correct, and yes, I have...
9
by: John Bailo | last post by:
I want to generate an Excel file (.xls format) from some database data. I don't want to use Excel.exe because of all the automation and security issues. Does Microsoft document the .xls file...
18
by: John Bailo | last post by:
I want to write an Excel file (.xls format) from some database data. I don't want to use Excel.exe because of all the automation and security issues. Does Microsoft document the .xls file...
3
by: blerina | last post by:
hi, i have a simple asp code that opens an excel file. it works fine with simple excel files that don't contain formula. i think the problem is that my excel file contains formulas and...
0
by: nudrat | last post by:
I have added a reference Microsoft Excel 5.0 Object Library in my project. the code is as follows: Dim myExcel As Excel.Application ' Interface to Excel Dim myWorkBookCollection As...
2
by: Lynch225 | last post by:
Hey all, I am having issues when trying to open an Excel file from Access VBA. Here's the code I have so far: Public Sub Prod() Dim xlApp As Object Dim xlWorkbook As Object Dim strProd As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.