Cells().Value syntax question

maubrey01

New Member
Joined
Jan 3, 2014
Messages
4
Hi,

My latest post revealed that I could highlight a keyword and hit F1 to find information on proper syntax. I did this, I've google'd search, and I've searched this form for ideas. But I am not coming up with anything helpful at the moment. Can someone identify what I am doing wrong?

Code:
Worksheet(1).Cells.(studentNumber - 11, studentNumber -11).Value = actualReceived

Thanks,

Mike
 

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.
Hi,

My latest post revealed that I could highlight a keyword and hit F1 to find information on proper syntax. I did this, I've google'd search, and I've searched this form for ideas. But I am not coming up with anything helpful at the moment. Can someone identify what I am doing wrong?

Code:
Worksheet(1).Cells.(studentNumber - 11, studentNumber -11).Value = actualReceived

It is a little hard to know what is wrong as you did not tells anything about your data or how it is laid out in the worksheet; however, the first argument to Cells is the row number an the second argument is the column number for the cell...you put the same number into both arguments which kind of sounds wrong (well, at least unexpected) to me.
 
Upvote 0
I'm not sure what context of the code description is that you are wanting. So, below is the entirety of what I have written. Please keep in mind that I have no coding experience what-so-ever. Everything I've learn is what I taught myself through youtube videos, trial and error, and this forum. Please, no judging my code!

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim i As Integer
Dim j As Integer


'========================================================================|
'Students can only earn points when they are present at school.  Likewise, they can                 |
'not earn points if they are absent from school.  If students are at school, they can       |
'earn five possible points.  If students are absent, they lose only one point.  The            |
'code below isolates the checkboxes that the user selects if a student is absent. Since  |
'there is 6 checkboxes per day per student, and the "Present" checkbox comes first,    |
'the code checks to see if every sixth box has been unselected.                                             |
'=========================================================================


For i = 1 To 750 Step 6 'isolates the "Present" checkbox for each day of the week
                                           ' per student
     If ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = True Then             'if the "Present" checkbox is checked
               For j = 1 To 5
                     ActiveSheet.OLEObjects("CheckBox" & i + j).Object.Enabled = True  'Then the next five sequential checkboxes
               Next j                                                                                                                            'are enabled so the user can choose to
                                                                                                                                                      'deselect any of them as needed.
       Else
               For j = 1 To 5                                                                                                                 'if the "Present" checkbox is not checked
                     ActiveSheet.OLEObjects("CheckBox" & i + j).Object.Enabled = False    'then the next five sequential checkboxes
                     ActiveSheet.OLEObjects("CheckBox" & i + j).Object.Value = False         'are unchecked and are disabled.  This prevents
              Next j                                                                                                                                'the students from losing points if they are not
       End If                                                                                                                                      'at school.
Next i




'==========================================================================
'The following code is an attempt to calculate student scores
'==========================================================================


Dim m As Integer
Dim n As Integer
Dim p As Integer
Dim studentNumber As Integer
Dim actualReceived As Integer
Dim psuedoReceived As Integer
Dim presentReceived As Integer
Dim enabledReceived As Integer




For m = 1 To 721 Step 30                    '1 student = 30 checkboxes
       studentNumber = studentNumber + 1  'keeps track of which student I'm on


   For n = m To (m + 29)              'Isolates (a range of) 30 checkboxes per student
       If ActiveSheet.OLEObjects("CheckBox" & n).Object.Value = True Then  'Counts all true checkboxes within student's range
              psuedoReceived = psuedoReceived + 1
        Else
       End If


       If ActiveSheet.OLEObjects("CheckBox" & n).Object.Enabled = True Then 'Counts all enabled checkboxes within student's range
              enabledReceived = enabledReceived + 1
       Else
       End If
   Next n
       
   For p = m To (p + 29) Step 6    'Isolates PRESENT checkboxes
       If ActiveSheet.OLEObjects("Checkbox" & n).Object.Value = True Then 'Counts all true "Present" checkboxes" within studnet's range.
              presentReceived = presentReceived + 1
       Else
       End If
   Next p


   actualReceived = psuedoReceived - presentReceived
   Worksheet(1).Cells.(studentNumber - 11, studentNumber -10).Value = actualReceived
   Worksheet(1).Cells.(studentNumber - 11, studentNumber - 11).Value = enabledReceived




Next m


End Sub
 
Upvote 0

Forum statistics

Threads
1,203,026
Messages
6,053,113
Members
444,639
Latest member
xRockox

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