| | |
excel vba
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
hi there, i am new to excel VBA. can anyone help me how to copy all the data in excel to another excel sheet by means of visual basic. for example excel1 and excel2.. after i locate excel1, then when i click copy button, it will copy all the data in excel1 and open a new sheet, excel2 having the same data contents exactly as excel1.. any idea.. thanks
•
•
•
•
same data contents exactly as excel1
A good excercise for the Heart is to bend down and help another up...
Please Mark your Thread "Solved", if the query is solved...
==>If a post has helped you then Please Rate it!
Please Mark your Thread "Solved", if the query is solved...
==>If a post has helped you then Please Rate it!
Here is the idea, i have an excel file which contains data(say excel1). In my visual basic form, i have 'locate file' button, (for locating excel1). After i locate excel1 for whatever path it is located, when i press 'process' button', it will automatically create a new excel file (say excel2) which now contains same data as excel1 BUT with formatted data, which means data in excel2 is now processed.. For example, the columns in excel2 was set autofit, the fonts for selected rows/columns were bold, having font color red or blue, with fontsize 16, and the data for a particular columns were computed by means of setting formula to specified columns etc. etc.. In short, manual formatting and computing in excel (so no more human effort) were now automated thru visual basic, i think it can be done with visual basic (excel vba for an instance). I'm new to excel vba and now ready to explore further as i can, and asking whosoever here professional in excel vba if it is possible to create a new excel file with the same data as old excel file. For now, i am just on formatting fontcolor, sizes and still on the way on how to set the formula in excel thru visual basic.. Hope you guys know what i mean. Thank you for reading and hope i can get idea for anyone. God bless..
Last edited by arvin2006; Apr 1st, 2009 at 8:46 pm.
hi arvin2006, check this simple vbscript..it will copy excel1 to excel2.. just change the path as necessary..
and on you excel2 workbook copy this code
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") FSO.CopyFile "c:\excel1.xls", "c:\excel2.xls" 'change the path as necessary 'copy excel1 to excel2 Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run ("C:\excel2.XLS") 'activate or runs the copied file
and on you excel2 workbook copy this code
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'to do formatting on selected cells Private Sub Workbook_Open() Range("A1").Select Selection.Font.ColorIndex = 3 Range("A2").Select Selection.Font.Bold = True End Sub
hi arvin, you can use this on vba to copy file...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
dim str_SourceFile as String dim str_DestinationFile as String 'str_SourceFile path of the source file 'str_DestinationFile path of the destination file FileCopy str_SourceFile, str_DestinationFile
![]() |
Similar Threads
- Sendkeys in excel vba (Visual Basic 4 / 5 / 6)
- Copying Tables From Word and Pasting in Excel in VBA (Visual Basic 4 / 5 / 6)
- Coding in Excel using VBA (Community Introductions)
- help with excel vba (Visual Basic 4 / 5 / 6)
- Find Method problem in Excel VBA.... (Visual Basic 4 / 5 / 6)
- VBA source code (Visual Basic 4 / 5 / 6)
- C++ or Excel and VBA in Finance? (C++)
- Compiling Excel VBA-code? (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Collection object with flexgrid
- Next Thread: replacing variable data..(pls very urgent)
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






