VBA Sub procedure

mpstorey

New Member
Joined
Nov 7, 2010
Messages
4
Hey everyone , I was wondering if you help me. I'm having a very difficult time creating a sub procedure for the following problem.

Here it is.


to write a [FONT=Times New Roman,Times New Roman][FONT=Times New Roman,Times New Roman]VBA sub procedure [/FONT][/FONT]called [FONT=Times New Roman,Times New Roman][FONT=Times New Roman,Times New Roman]Timetable [/FONT][/FONT]to help him automate the conversion of his daily schedule to a timetable. Your sub procedure should read information stored in cells A2 to D5 and convert this data into a timetable as shown below. For your sub procedure you may use the following assumption:
-Time is displayed in military format (24 hours)
-You instructor always has 4 schedules per day
-Every meeting would start and end right on the hour (meeting would last at least

Here is a link for what the layout is suppose to be
www.wix.com/mpstorey/Timetable

thanks a lot , your help is very appreciated
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Must be the start of a new semester...or at least close to exam time. This looks an awful lot like a homework assignment to me.
 
Upvote 0
Hey, yes its assignment number 3 out of 4 , the prof said it was easy but its hard to go though the processes with him as he teaches. It gets very confusing
 
Upvote 0
ha! well at least you're honest. Most times people try to pass it off as some work assignment their boss just dumped in their laps and they just so happened to phrase it like a school assignment...give me a bit and I'll see if I can hack something together. Maybe someone will come along in the meantime and get you something (but to warn you, most won't knowing it's a homework assignment).
 
Upvote 0
Thanks a lot! this mean a lot man..I dont need the answer exactly, im just trying to get started. If you can even just help me with the first column and i can try to go from there.
 
Upvote 0
OK, this is how I'd do it:

Code:
Sub Timetable()
Dim rTime As Range, rHighlight As Range
Dim lStart As Long, lEnd As Long, i As Long
Dim sStartDate As String, sEndDate As String

Sheet1.Range("B10:C22").Delete

Set rTime = Sheet1.Range("A10:A22")

For i = 2 To 5
sStartDate = Format(Sheet1.Range("B" & i).Value, "h:mm")
sEndDate = Format(Sheet1.Range("C" & i).Value, "h:mm")

lStart = rTime.Find(What:=sStartDate, After:=Sheet1.Range("A10"), LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Row
lEnd = rTime.Find(What:=sEndDate, After:=Sheet1.Range("A10"), LookIn:=xlValues, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Row
        
Sheet1.Range("B" & lStart) = Sheet1.Range("A" & i).Value
Sheet1.Range("C" & lStart) = Sheet1.Range("D" & i).Value

Sheet1.Range("B" & lStart & ":C" & lEnd - 1).Interior.ColorIndex = i + 2
    
Next i

End Sub

Here are my assumptions:

1) Grid is on sheet1 of the workbook
2) Timetable grid is on Sheet1!A10 to Sheet1!C22
3) All times are formatted as military time (I used the "h:ss" custom format).

Let me know if you'd like me to email you my test workbook as a reference.
 
Upvote 0
You'll have to be a bit more specific...what didn't work, or how didn't it work? Seemed to work on my test sheet.

What specifically are you trying to do?
 
Upvote 0

Forum statistics

Threads
1,225,203
Messages
6,183,550
Members
453,168
Latest member
Luggsy

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