PC Review


Reply
Thread Tools Rate Thread

copy certain data in a excel to another excel

 
 
^^
Guest
Posts: n/a
 
      12th Sep 2007
im making an application automating the reporting process
usually i do it manually by copy-paste the information to one another
i have very little experience in vb and none in macro
here is what the application should do

1.open a new xls file
2.open new worksheet in the new xls file and rename it
3.open a few data xls files
4.copy certain data in the xls files and arrange in accordingly in the
worksheet

step 2-4 is looping depending on how much worksheet or data needed in
one workshet

5.save the new xls file

you guys have any idea? please help
atleast give me some links or tips on where to learn macro or vb fast

thanks

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      12th Sep 2007
here is some code that may help


Sub TimeCard()

Const MasterPath = "c:\temp\time cards"
Dim DateColumnArray(16, 2)

'Application.ScreenUpdating = False

Set fso = CreateObject _
("Scripting.FileSystemObject")

Set folder = _
fso.GetFolder(MasterPath)

SelectEmployeeForm.SelectEmployeeBox.Clear
If folder.subfolders.Count > 0 Then
For Each sf In folder.subfolders
EmployeeDir = sf
'strip off path from filename
Do While InStr(EmployeeDir, "\") > 0
EmployeeDir = Mid(EmployeeDir, InStr(EmployeeDir, "\") + 1)
Loop
SelectEmployeeForm.SelectEmployeeBox.AddItem EmployeeDir

Next sf
End If

'Custom userform, not standard VBA
SelectEmployeeForm.Show
Employee = SelectEmployeeForm.SelectEmployeeBox.Value

TimeSheetWB = Employee + " Time Sheet.xls"
TimeCardWB = Employee + " Daily Timecard.xls"

Workbooks.Open Filename:="c:\temp\time cards" + "\" + Employee + _
"\" + TimeSheetWB

'wait one second for last listbox to clear
'need this so the listbox will be visable
Application.Wait (Now + TimeValue("0:00:1"))

SelectWorksheetForm.SelectWorksheetBox.Clear
For Each ws In Worksheets

SelectWorksheetForm.SelectWorksheetBox.AddItem ws.Name
Next ws

SelectWorksheetForm.Show
StringPayPeriod = SelectWorksheetForm.SelectWorksheetBox.Value

Sheets(StringPayPeriod).Activate

Set DateRange = Range("E7:T7")

Count = 1
'wait one second for last listbox to clear
'need this so the listbox will be visable
Application.Wait (Now + TimeValue("0:00:1"))
SelectDateForm.SelectDateBox.Clear
For Each cell In DateRange
MyString = cell + " - " + _
CStr(Cells(cell.Row + 2, cell.Column))
SelectDateForm.SelectDateBox.AddItem MyString
DateColumnArray(Count, 1) = MyString
DateColumnArray(Count, 2) = cell.Column
Count = Count + 1

Next cell

'custom userform, not standard excel
SelectDateForm.Show
SelDate = SelectDateForm.SelectDateBox.Value

For Count = 1 To 16

If StrComp(SelDate, DateColumnArray(Count, 1)) = 0 Then
Exit For
End If
Next Count

CopyColumnNum = DateColumnArray(Count, 2)


Application.ScreenUpdating = False


'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
'OPEN DAILY TIMECARD
Workbooks.Open Filename:="c:\temp\time cards" + "\" + Employee + _
"\" + TimeCardWB

'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


Windows(TimeSheetWB).Activate
Sheets(StringPayPeriod).Activate


Application.WindowState = xlMaximized


'Application.ScreenUpdating = False

'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
'LOAD DATA FROM TIMESHEET INTO DAILY TIMECARD
Windows(TimeCardWB).Activate

Range("G7").Select
ActiveCell.FormulaR1C1 = "='[" + TimeSheetWB + "]" + StringPayPeriod +
"'!R9C" + CStr(CopyColumnNum)

Application.ScreenUpdating = False

OffsetCount = 0


"^^" wrote:

> im making an application automating the reporting process
> usually i do it manually by copy-paste the information to one another
> i have very little experience in vb and none in macro
> here is what the application should do
>
> 1.open a new xls file
> 2.open new worksheet in the new xls file and rename it
> 3.open a few data xls files
> 4.copy certain data in the xls files and arrange in accordingly in the
> worksheet
>
> step 2-4 is looping depending on how much worksheet or data needed in
> one workshet
>
> 5.save the new xls file
>
> you guys have any idea? please help
> atleast give me some links or tips on where to learn macro or vb fast
>
> thanks
>
>

 
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 Data from Excel 2007 XLSM workbook to Excel 2003 XLS workbook using ADO Andy Microsoft Excel Programming 2 27th Jul 2007 10:44 PM
copy data from excel 1 to excel 2 when different dates and columns =?Utf-8?B?SmltIGF0IEVhZ2xl?= Microsoft Excel Programming 1 13th Apr 2007 10:16 AM
Excel --> Excel data copy truncated at 255 characters KunzLeigh Microsoft Excel Worksheet Functions 1 7th Feb 2007 10:08 PM
automatically copy selected data from one excel to other excel =?Utf-8?B?cmFqYQ==?= Microsoft Excel Programming 2 6th Sep 2005 01:41 PM
Excel 2002 cannot copy data from website to excel =?Utf-8?B?Q0pNY0JyaWRl?= Microsoft Excel Misc 1 6th Feb 2004 09:18 PM


Features
 

Advertising
 

Newsgroups
 


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