Which Variable to use?

AndrewKent

Well-known Member
Joined
Jul 26, 2006
Messages
889
Hi there,

On my last few threads I have been asking questions about how to best declare variables. After reading through the excellent content on C Pearsons website I now have a better understanding of how to declare a variable.

What it doesn't give me however is a list of what variables to use in certain situations. For example...

Text would be As String
Number would be As Intiger
True would be As Boolean

...does anyone have a list of what variables to use and when?

Andy
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Thanks, what variable should I use for this...

Code:
DeleteCode = Application.InputBox("Please enter the delete code")
 
Upvote 0
Thanks! I'm going through and properly declaring all my variables, there are about 46,000 lines of code so expect a few questions over the next few days!

Cheers again,

Andy
 
Upvote 0
Okay next one...

Code:
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
        
    With OutMail
        .To = "" & DevelopmentAddress & ""
        .CC = ""
        .BCC = ""
        .Subject = "Connect: Gateway Error"
        .body = "Date: " & vbTab & vbTab & vbTab & Format(Now, "dd-mmmm-yyyy") & vbNewLine & _
        "Version Name: " & vbTab & "" & VersionName & "" & vbNewLine & _
        "Record ID: " & vbTab & vbTab & "" & RecordID & "" & vbNewLine & _
        "Connect Routine: " & vbTab & vbTab & "" & ConnectSubRoutine & ""
        .Send
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing

OutMail and OutApp?
 
Upvote 0
Assuming you are late binding, declare them both as Object.
 
Upvote 0
Excellent, okay next...

Code:
ActiveRow = Worksheets("Status History").Range("B" & Range("B65536").End(xlUp).Offset(1, 0).Row & "").Row

String?
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

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