EXCEL中如果输入一个数,然后自动让它乘以某个常数(第一列乘6,第二列乘4)

这个问题,我们只能用VBA来解决了

首先按alt+F11,打开宏VBA编辑器,将下面代码复制过去就OK了

   1:  Private Sub Worksheet_Change(ByVal Target As Range)
   2:      If Not IsNumeric(Target) Then End
   3:      
   4:     '第一种方案

5: If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then

'把A1和A10改成你需要的就OK了

   6:      Application.EnableEvents = False
   7:      Target = Target * 6
   8:      Application.EnableEvents = True
   9:      End If
  10:      
  11:      '第二种方案
  12:      If Not Application.Intersect(Target, Range("B1:B10")) Is Nothing Then   
           '把A1和A10改成你需要的就OK了
  13:      Application.EnableEvents = False
  14:      Target = Target * 4
  15:      Application.EnableEvents = True
  16:      End If
  17:      
  18:  End Sub
  19:   

你可能感兴趣的:(Excel)