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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,978
Members
448,934
Latest member
audette89

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