Worksheet_Change关于VBA中特定单词的@Scan Excel列 [英] Worksheet_Change concerning @Scan Excel column for specific word in VBA

查看:146
本文介绍了Worksheet_Change关于VBA中特定单词的@Scan Excel列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编译了以下代码:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("S3")) Is Nothing Then
    Select Case Range("S3")
        Case "Complete": Sample
        Case "In Progress": InProgress
    End Select
End If
End Sub

此工作表的主要功能更改从 S3 完成正在进行 C $ C>。我在列中有一系列的下拉列表,它们都需要执行关于例行程序,但我很难在特定列中选择整个范围。

The main function of this worksheet change is to read complete or in progress from a drop down list from cell S3. I have a series of drop down lists in a column which all need to perform the about routine but I'm having difficulty to select the whole range in a specific column.

推荐答案

您可以尝试这样来选择entier列:

You may try this to select the entier column :

Sheets(1).Range :S)

然后完整的代码:

'-- you can find last used row of your column and used that as well
'-- Dim LastRow as Long 
'-- LastRow = Range("S3").Rows.Count
'-- If Not Intersect(Target, Range("S3").Resize(LastRow)) Is Nothing Then
Private Sub Worksheet_Change(ByVal Target As Range) 
  If Not Intersect(Target, Range("S:S")) Is Nothing Then
    '-- change to proper letter case as if the case don't match then case fails..
    Select Case StrConv(Target.Value, vbProperCase)
      Case "Complete": Sample
      Case "In Progress": InProgress '-- not sure if you need to remove the space
    End Select
  End If
End Sub

这篇关于Worksheet_Change关于VBA中特定单词的@Scan Excel列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆