Assigning Integer to Rows

smpatty08

Board Regular
Joined
May 16, 2014
Messages
155
I have some code that counts how many rows of interest there are in a spreadsheet and I want it to assign numbers as variable to those rows. e.g. The used range is B12:L19 (8 rows) and I want to assign row 12 as 1, row 13 as 2, row 14 as 3, etc so that later in my code I can reference that number is a msgbox and display a comment in my sheet. The code I have is posted below. The lines in red are what I am having trouble with and how I am trying to use it later in my code. Any help is appreciated.

Code:
Sub DropStandard()
On Error GoTo Errhandler
Dim i, x, StdCount As Integer, NumStd() As String
Set InfoBox = CreateObject("WScript.Shell")
AckTime = 5
Application.ScreenUpdating = False


EnzymeCurve.Activate
For i = 1 To 25
If Range("B" & i).Text Like "Working standards" Then
    Debug.Print i
    StdCount = EnzymeCurve.Range(EnzymeCurve.Range("K" & i + 2), EnzymeCurve.Range("K" & i + 2).End(xlDown)).Rows.Count
    For x = 1 To StdCount
    If IsEmpty(Range("K" & i + 2)) = True Then
        Exit Sub
    Else
        [COLOR=#ff0000]NumStd(x) = x[/COLOR]
    End If
    Next x
    Exit For
End If
Debug.Print i
Next i

EnzymeCurve.Range("B7").Activate
Application.ScreenUpdating = True
Exit Sub


''''''''Formats Graph'''''''''''''''
DropOneStandard:
Range("N12:AJ22").ClearContents
Range("B19:L19").Select
With Selection.Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent2
    .TintAndShade = 0.399945066682943
End With
[COLOR=#ff0000]Select Case InfoBox.Popup("W" & NumStdx & " excluded from standard curve.", AckTime, "Information", 0)
    Case 1, -1
End Select
Range("B22").Value = "*W" & NumStdx & " excluded from standard curve."[/COLOR]
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.FullSeriesCollection(1).XValues = "='Enzyme Curve'!$G$12:$G$18"
ActiveChart.FullSeriesCollection(1).Values = "='Enzyme Curve'!$J$12:$J$18"
ActiveChart.FullSeriesCollection(2).XValues = "='Enzyme Curve'!$G$19"
ActiveChart.FullSeriesCollection(2).Values = "='Enzyme Curve'!$J$19"
ActiveChart.FullSeriesCollection(2).MarkerStyle = xlMarkerStyleX
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.FullSeriesCollection(2).Select
With Selection.Format.Line
    .Visible = msoTrue
    .ForeColor.ObjectThemeColor = msoThemeColorAccent2
    .ForeColor.TintAndShade = 0
    .ForeColor.Brightness = 0
    .Transparency = 0
End With
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Copy
QuadraticWork.Select
Range("J15").Select
ActiveSheet.Paste
ActiveChart.FullSeriesCollection(1).Trendlines(1).Select
With Selection
    .Type = xlPolynomial
    .Order = 2
End With
Range("C5:E5").ClearContents
Range("C5").FormulaR1C1 = "=LINEST('Enzyme Curve'!R12C10:R18C10,'Enzyme Curve'!R12C7:R18C7^{1,2})"
Range("C5:E5").FormulaArray = _
    "=LINEST('Enzyme Curve'!R12C10:R18C10,'Enzyme Curve'!R12C7:R18C7^{1,2})"
Range("J12:M12").Select
With Selection.Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent2
    .TintAndShade = 0.399945066682943
End With
Range("B7").Activate
Exit Sub


''''''''''Error handler to log and report issue to user'''''''''''''
Errhandler:
ErrorLine = Erl
strModule = Application.VBE.ActiveCodePane.CodeModule: Debug.Print strModule
Set CodeMod = Application.VBE.ActiveCodePane.CodeModule
With CodeMod
    LineNum = .CountOfDeclarationLines + 1
    Do Until LineNum >= .CountOfLines
        ProcName = .ProcOfLine(LineNum, ProcKind)
        LineNum = .ProcStartLine(ProcName, ProcKind) + _
        .ProcCountLines(ProcName, ProcKind) + 1
    Loop
End With
Call ErrorHandler.ErrorHandler
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
For the first, where is the function NumStd()? I don't know why you would want a True or False equality there either.

For the 2nd, you either don't have InfoBox reference set and/or variable NumStdx does not exist. Likely, NumStdx is the problem as it is for the last error line.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,629
Messages
6,120,630
Members
448,973
Latest member
ChristineC

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