We help IT Professionals succeed at work.
Get Started

Alternative to select function in VBA?

908 Views
Last Modified: 2016-02-11
I use a  excel woorkbook with some VBA in it and are excerpering a problem. The workbook works great when it's the only workbook open, but when other workbooks also are open, my workbook tend to crash when switching between workbooks and entering data in the cells.

I don't really know what's causing the problem, but I suspect it to be something with the use of SELECT. Therefore I want to get rid of the select functions to test if that is causing the crashes.

The code is attached to dropdown list (using datavalidation), there the users can choose between different types of how to show data:
 
If Target.Address = "$C$10" Then
    
    Range("C28:D89,I28:J89,O28:P89,U28:V89").Select
    
    Select Case Cells(10, 6)
    
        Case 0
            Selection.NumberFormat = "0"
        
        Case 1
            Selection.NumberFormat = "0.0"
        
        Case 2
            Selection.NumberFormat = "0.00"
        
        Case 5
            Selection.NumberFormat = "0%"
        
        Case 6
            Selection.NumberFormat = "0.0%"
            
        Case 7
            Selection.NumberFormat = "0.00%"
            
    End Select
 
    Range("C10").Activate
    
End If

Open in new window


Any alternatives to the SELECT function?
Comment
Watch Question
Excel & VBA Expert
CERTIFIED EXPERT
Most Valuable Expert 2018
Awarded 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE