From excel timesheet create a import file csv

Kaz5208

New Member
Joined
Nov 7, 2019
Messages
6
Hi, really hoping for some help please.
I have a excel timesheet which details hours worked against different pay elements. For example , columns would be ...
Ee no., name, no.of hrs, hourly rate, total pay. Header above theses columns would be PE Basic pay( 88). Following to the right , the next columns would be again, no.of hours, hourly rate, total pay. However the header above this set of columns would be PE overtime 1.5 (89) .

I am looking to create a csv file from this data. We currently copy and paste, but this is taking an age!!!
I would need the columns in the following order.

Ee no. PE code I.e 88, no. of hours, hourly rate
We dont need the data rows where there are no hours for a pay element, so need to delete those.
Then directly under the data rows have Ee no. PE code 89, no.of hours, hourly rate. So the import file is effectively has 4 columns but many rows.

Hope the above makes sense... I would appreciate any help.
Many thanks in advance
 
WOW!! thank you. This is amazing!!
Where do you learn this stuff from? Can you just explain the key actions like DIM & AS long? thanks. I would really like to learn this vba as I have other timesheet layouts i would like to apply this logic to and create import files.

The only bit i have a problem with is

'Save file
wPath = "C:\trabajo\"
wFile = "Import file creation.csv"
sh2.Copy
ActiveWorkbook.SaveAs Filename:=wPath & wFile, FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close False
MsgBox "End"

End Sub

I get an error 400 on my macbook. Something about active object?

ActiveWorkbook.SaveAs Filename:=wPath & wFile, FileFormat:=xlCSV, CreateBackup:=False

Do i need to change the "C:\trabajo\" to destination of my choice?

Thanks once again, this is going to save me soo much time!!!
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
WOW!! thank you. This is amazing!!
Where do you learn this stuff from? Resolving user doubts. I don't use any of this in my work, hehe.

Can you just explain the key actions like DIM & AS long? This is used to declare a variable, the variables are used to store data, and you must specify the type of variable, Long is a type of variable. Check the following link:


The only bit i have a problem with is

'Save file
wPath = "C:\trabajo\" Yes, change this information to the name of your folder.

I get an error 400 on my macbook. Something about active object?
ActiveWorkbook.SaveAs Filename:=wPath & wFile, FileFormat:=xlCSV, CreateBackup:=False
Do i need to change the "C:\trabajo\" to destination of my choice?

Thanks once again, this is going to save me soo much time!!!

I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,028
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top