Declare varaible cell contents without selecting/close userform opening automatically

buzz71023

Active Member
Joined
May 29, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
I am in need of a better way to declare this variable without actually selecting the cell.
Issue I am having is in this range I also have another code activate a userform when a cell in this range is selected.
I need the code to search/find the last cell used in the range and then declare the contents of that cell to globTime without opening the userform.
OR
what am I doing wrong to close this userform (Unload frmTime1)

VBA Code:
'Activate userform when cell is selected
If Not Application.Intersect(Target, Range("TimeLedger")) Is Nothing Then
      frmTime1.Show
             End If

VBA Code:
'get the last end time for nextjob start time
Dim xLastRow As Long

With Application.ActiveSheet.Range("EndTimeCol")
     xLastRow = .Cells(.Rows.Count, "a").End(xlUp).Select
          End With
                   
Unload frmTime1  [B]'This is not unloading the userform when it pops up[/B]

globTime = ActiveCell.Value 'This variable  public declared (as Double)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Perhaps.
VBA Code:
'get the last end time for nextjob start time
With ActiveSheet.Range("EndTimeCol")
     globTime = .Cells(.Rows.Count, "a").End(xlUp).Value
End With
                   
Unload frmTime1
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,977
Members
449,095
Latest member
Mr Hughes

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