Homework_1 String Variable Concat CRLF

Send Snippet To: Save this snippet to Code Collector Pro -- view all surfrgeek's snippets
language: Other
license: Other

Code for Snippet:

                
'*******************************************************************
'PURPOSE: String Variable / Concatenate / Carriage Return & Linefeed
'AUTHOR: John Stairs
'DATE: 8/17/2017
'*******************************************************************
 
Sub Greetings()
 
    Dim myString As String 'declare a string variable
 
    myString = Worksheets("Greetings").Range("A1").Value 'assign Range a1's value into my string variable
 
    Worksheets("Greetings").Range("A3").Value = myString & " World!"  'assign modified my string into Range A3
 
    Worksheets("Greetings").Range("A4").Value = myString & " " & myString & " " & myString
 
    Worksheets("Greetings").Range("A5").Value = myString & " and Goodbye!"
 
    myString = Worksheets("Greetings").Range("A5").Value & vbCrLf & "May we meet again!" 'formulate a new my string
 
    'Display the modified my string in a message box
    MsgBox myString, vbInformation, "Greetings"
 
End Sub
 
Sub CountHighSales()
 
    Dim i As Integer
    Dim j As Integer
    Dim msg As String
    Dim numberHigh As Integer
    Dim salesCutoff As Currency
 
    msg = ""
 
    salesCutoff = InputBox("What sales value do you want to check for?" _
                                & vbCrLf _
                                & "Enter a value and Press OK")
    For j = 1 To 6
        numberHigh = 0
 
        For i = 1 To 36
            If Worksheets("Sales").Range("B2:G37").Cells(i, j) > salesCutoff Then
                numberHigh = numberHigh + 1
                Range("B2:G37").Cells(i, j).Font.Color = vbRed
 
            End If
 
        Next i
        msg = msg & "For region " & j & ", sales were above " & Format(salesCutoff, "$0,000") _
            & " on " & numberHigh & " of the 36 months." & vbCrLf
 
    Next j
 
    MsgBox msg
 
End Sub
 
Sub ClearHighlights()
 
    Worksheets("Sales").Range("B2:G37").ClearFormats
 
End Sub
 
comments powered by Disqus

Info

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 17
Date Added: 2017-09-06 16:35:31
Last Modified: 2017-09-09 14:05:31

Web Analytics