Need help with Visual Basic Editor, I am confussed on this.

susiesc

New Member
Joined
Mar 24, 2013
Messages
29
I am to delcare a new variable new_obs and then set the variable to integer.
And below the comments at the top of the sub procedure, enter the following statements:
This variable will store the observation number of the quality control sample.

After I do that I have to set the value of the new_obs variable equil to one
plus the value of cell A3 in the QC Data worksheet.

I am given a hint: Use an object reference that includes the object hierarchy from sheets collection to the range object.

So this is what I have already done

This variable will store the observation number of the quality control sample.
Public Sub new_obs()
Dim num1 As Integer =1, QC Data A3


I am more confussed :eek: now then I was before, once I added them all came out red with errors.
Please help me understand how I am to write this please....


Susie
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try like this

Code:
Sub atest()
Dim new_obs As Integer
new_obs = Sheets("QC Data").Range("A3").Value + 1
MsgBox new_obs
End Sub
 

T0rM3nT

New Member
Joined
Apr 24, 2013
Messages
3
Code:
Sub FunctionName()

    'This variable will store the observation number of the quality control sample
    Dim new_obs As Integer

    new_obs = Sheets("QC Data").Range("A3").Value + 1
    MsgBox (new_obs)

End Sub

Try this. You can remove the MsgBox line if you want. It will just display the value of the new_obs variable.

EDIT: Woops, didn't realize someone had already responded with basically the same code.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,711
Messages
5,833,251
Members
430,200
Latest member
ADLHMA2022

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