AS String Problem

fpskidmark

Board Regular
Joined
Sep 11, 2009
Messages
139
Hi All,

I'm getting a "Compile Error" msg - "Expected Sub, Function, or Property" for this "DT" value
PHP:
 [If Cells(36, n) = "Vicki " Then DT:/PHP]
 
Can someone please help me?
 
[PHP]
Dim t As String
Dim LC As Long
Dim DT As String
DT = Workbooks("RCO Schedule.xls").Sheets("2011").Range("c3:gb3").Find(t).Column
Jan = Workbooks("RCO Schedule.xls").Sheets("2011").Cells(7, DT)
VicM = Workbooks("RCO Schedule.xls").Sheets("2011").Cells(9, DT)
VicG = Workbooks("RCO Schedule.xls").Sheets("2011").Cells(38, DT)
Cor = Workbooks("RCO Schedule.xls").Sheets("2011").Cells(32, DT)
MsgBox (DT)
Sheets("OT").Select
On Error Resume Next
LC = Cells(37, Columns.Count).End(xlToLeft).Column
For n = 3 To LC Step 1
t = Cells(3, n).Value
If Cells(2, n) = "" Then GoTo July
If Cells(36, n) = "Vicki " Then DT: VicM.FormulaR1C1 _
= VicM & " - " & Workbooks("RCO Schedule Worksheet.xls").Sheets("OT").Cells(5, n): VicM.Font.ColorIndex = 9

Thanks,
FP
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
So it's the exact same code for each of the 28 person with only the row they are located on changing?

You might be able to do that by looping through the names and/or their row location.

Can you post code for more than one person?

By the way, is the code actually written with all these long lines and continuation characters?

That makes it pretty hard to follow - it doesn't even post quite right.:)

In fact I've just tried to work out what the code is meant to do but I've given up.

You have one line of code that has over 400 characters in it.:eek:

I did manage to single out one line of code, this:
Code:
Workbooks("RCO Schedule.xls").Sheets("2011").Range("c3:gb3").Find(t).Column
But I'm not sure if that's right because it doesn't mean or do anything.

It uses Find to look for whatever t is and then it returns the Column, but where to?

Sorry if I'm being thick here but I really can't follow the code.:)
 
Upvote 0
This code is unfortunately not very readable.

Can you explain in words what it is meant to do and give an example of data and the results after it has executed. If possible, used a simplified data set (maybe just two or three employees instead of 28).
 
Upvote 0
Thanks for trying, Norie. I’m sorry the code is difficult to read (that’s why I need to simplify it)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
I modified the code a little, hopefully it makes more sense<o:p></o:p>
<o:p></o:p>
What I'm trying to do is, if an employee is granted OT (Sheets("OT")), then go to the schedule and update the OT information on the schedule sheet (Sheets("2011").<o:p></o:p>
<o:p></o:p>
Ex. below Vic = the range where "Vicki Marino" and the OT date("T") meets on the schedule - (Cells(9,162))<o:p></o:p>

PHP:
Dim t As String
Dim LC As Long
Dim OTT As String
Dim OTA As String
Dim Vic As Range
 
Sheets("OT").Select
On Error Resume Next
LC = Cells(37, Columns.Count).End(xlToLeft).Column
For n = 3 To LC Step 1
t = Cells(3, n).Value
 
OTT = Workbooks("RCO Schedule Worksheet.xls").Sheets("OT").Cells(4, n)
OTA = Workbooks("RCO Schedule Worksheet.xls").Sheets("OT").Cells(5, n)
Vic = Workbooks("RCO Schedule.xls").Sheets("2011").Cells(9, Workbooks("RCO Schedule.xls").Sheets("2011").Range("c3:gb3").Find(t).Column)
 
If Cells(2, n) = "" Then GoTo July
 
If Cells(36, n) = "Vicki Marino" Then Vic.Formula = Vic & OTT & OTA: Vic.Font.ColorIndex = 9

Thanks for your help,
FP
 
Upvote 0
I finally got it! Thanks guys!

PHP:
Dim t As String
Dim LC As Long
Dim OTT As String
Dim OTA As String
Dim Vic As Range
 
 
Sheets("OT").Select
On Error Resume Next
LC = Cells(37, Columns.Count).End(xlToLeft).Column
For n = 3 To LC Step 1
t = Cells(3, n).Value
 
OTT = Workbooks("RCO Schedule Worksheet.xls").Sheets("OT").Cells(4, n)
OTA = Workbooks("RCO Schedule Worksheet.xls").Sheets("OT").Cells(5, n)
Set Vic = Workbooks("RCO Schedule.xls").Sheets("2011").Cells(9, Workbooks("RCO Schedule.xls").Sheets("2011").Range("c3:gb3").Find(t).Column)
  
If Cells(2, n) = "" Then GoTo July
 
If Cells(36, n) = "Vicki Marino" Then Vic.FormulaR1C1 = Vic & "," & OTT & " - " & OTA: Vic.Font.ColorIndex = 9

Have a great weekend,
FP
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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