Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Magenta Ricci   on Nov 02 In MS Office Category.

  
Question Answered By: Skye Hughes   on Nov 02

From your description, it sounds like a Public or Global variable  will work
fine. Is your macro something like this?

Public Prev As Integer

Sub TEST()
Dim x As Integer
'Set default value for Prev%.
If Prev% = 0 Then
Prev% = Selection.Rows.Count
End If
'Count the vertical cells selected.
x% = Selection.Rows.Count
'If 1 cell is selected, move Prev% * 3 columns
'to the right.
If x% = 1 Then
ActiveCell.Offset(x% - 1, Prev% * 3).Activate
Else
'If more than one cell is selected, move x% * 3
'columns to the right.
ActiveCell.Offset(x% - 1, x% * 3).Activate
End If
'Store the number of vertical cells selected this time.
Prev% = x%
End Sub

Share: 

 

This Question has 9 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on how to preserve variable value between subroutine calls? Or get search suggestion and latest updates.


Tagged: