Hello,
So I made a column, and placed some formulas in there to provide a number based on other cells.
Within VBA I am trying to set a different range equal to a specific percentage. The percentage would be either 25%, 50% or 75% depending on whether the corresponding amounts in the first range (if larger than 3, 25%, larger than 5, 50%, and larger than 10, is 75%); however, I am currently stuck, and not sure what I am doing wrong. Please see code below.
I feel like I'm using the wrong variable type for OfficeYears, but not sure.
So I made a column, and placed some formulas in there to provide a number based on other cells.
Within VBA I am trying to set a different range equal to a specific percentage. The percentage would be either 25%, 50% or 75% depending on whether the corresponding amounts in the first range (if larger than 3, 25%, larger than 5, 50%, and larger than 10, is 75%); however, I am currently stuck, and not sure what I am doing wrong. Please see code below.
Code:
[FONT=Verdana]'**Sets Variable For Current Workbook
Dim WorkBook1 As Workbook
Set WorkBook1 = ThisWorkbook
[/FONT]
[FONT=Verdana]'**Sets Variable For Rent_Roll Sheet
Dim Worksheet1 As Worksheet
Set Worksheet1 = WorkBook1.Worksheets("Sheet 1")
[/FONT]
[FONT=Verdana]'**Sets Variables For Range to include Percentages
Dim OfficeSC As Range
Dim OfficeRange As Range
Set OfficeSC = Worksheet1.Range("Q16")
Set OfficeRange = Range(OfficeSC, OfficeSC.End(xlDown))
'**Sets Variables For Years Column
Dim OfficeYears As Variant
Set OfficeYears = OfficeRange.Offset(0, 4)
'''Runs IF and sets percentages based on years.
If OfficeYears > 10 Then
OY = 75
ElseIf OfficeYears > 5 Then
OfficeRange = 50
ElseIf OfficeYears > 3 Then
OfficeRange = 25
End If[/FONT]
I feel like I'm using the wrong variable type for OfficeYears, but not sure.