Cell value into a variable

cccbzg

Board Regular
Joined
Oct 5, 2014
Messages
63
Hello,

I am getting an error on the line in red. Can't figure out why?? Something wrong with my syntax. Uggg. I'm trying to put a cell value into a variable called ENDHONORS. The cell value comes from a Msgbox entry and a line counter (i).

Any help would be much appreciated.

Thanks,
Bonnie

Sub HHPP()
With Sheets("WORKBOOK")
STUDENTcount = Sheets("WORKBOOK").Range("C" & 1).Value

lFinalRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rngColA = .Range(.Cells(1, "B"), .Cells(lFinalRow, "B"))
End With

MsgBox "Number of students " & lFinalRow
Dim Honors As Integer
Dim HighPass As Integer
Dim Pass As Integer
Dim ENDHONORS As Double
Dim ENDHIGHPASS As Double

Honors = lFinalRow * 0.45
HighPass = lFinalRow * 0.4
Pass = lFinalRow * 0.15
HonorsHighPass = Honors + HighPass

MsgBox "honors count " & Honors
'MsgBox Honors

' Go through the rows

Sheets("WORKBOOK").Select

'** For Each cell In rngColA.Cells

Dim Selcol As String

Selcol = Application.InputBox("Enter Column code containing grades")

For i = 2 To lFinalRow

'Which column should be used to make the determination

If i = Honors Then ENDHONORS = Range(Selcol & i).Values
If i = Honors Then MsgBox "End of honors range " & ENDHONORS

If i = HonorsHighPass Then ENDHIGHPASS = Range(Selcol & i).Values
If i = HonorsHighPass Then MsgBox "End of High pass range " & ENDHIGHPASS
'
Next i



End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Alex Blakenburg

Well-known Member
Joined
Feb 23, 2021
Messages
568
Office Version
  1. 365
Platform
  1. Windows
I don't know if I am missing something but there is no property called Values.
If you replace your 2 references using .Values to .Value does it work ?

Too slow but edit won't let me delete. :)
 

cccbzg

Board Regular
Joined
Oct 5, 2014
Messages
63
OMG. Feel quite silly, but still glad I posted. Just couldn't see that. Too late to be working.o_O

Thanks SO much!
 

StephenCrump

MrExcel MVP
Joined
Sep 18, 2013
Messages
4,124
Office Version
  1. 365
Platform
  1. Windows
No problem, we've all been there. Glad we could help.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,513
Messages
5,636,778
Members
416,939
Latest member
Rajakumaran

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
Top