ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   MAcro Needed (https://www.excelbanter.com/excel-discussion-misc-queries/113390-macro-needed.html)

Nimish

MAcro Needed
 
How do you write a macro that takes a 7 day schedule with Employee ID
and create a csv file that shows:

ID, Date, Scheduled Start


Anyone have a way to take a table and then pull each column with the
associated ID and stack this data?


Tom Ogilvy

MAcro Needed
 
Pseudo code should get you started. You know the details.

Sub CreateCSV(id as String, rng as Range)
Dim ff as Long, cell as Range
Dim line as String, rng1 as Range
ff = FreeFile()
open "C:\MyFile\" & id & ".csv" for output as #ff
for each cell in rng.columns(1).Cells
'Detailed code goes here
set rng1 = cell.Resize(1,4)
line = ""
for each cell in rng1
line = line & cell.Value & ","
Next
line = left(line,len(line)-1)
Print line
Next
End sub

Sub StackData(id as String, rng as Range)
for each cell in rng.columns(1).Cells
' detailed code goes here
Next
End Sub

sub Tester()
CreateCSV "ABCD", Range("A2:Z200")
StackData "ABCD", Range("A2:Z200")
End Sub

--
regards,
Tom Ogilvy


"Nimish" wrote in message
oups.com...
How do you write a macro that takes a 7 day schedule with Employee ID
and create a csv file that shows:

ID, Date, Scheduled Start


Anyone have a way to take a table and then pull each column with the
associated ID and stack this data?





All times are GMT +1. The time now is 08:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com