本文介绍了在代码定义的范围内搜索€符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有VBA编码经验.

I am not experienced in VBA coding.

我的VBA代码:

Search = InStr(ActiveCell.NumberFormat, Chr(128))
Selection.Find(What:=Search, After:=ActiveCell, LookIn:=xlValues, _
  LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
  MatchCase:=False, SearchFormat:=False).Activate

它搜索并激活包含€符号的单元格.仅当我手动定义选择范围时,它才有效.

It searches and activates the cells which include the € symbol. It works only if I manually define my selection range.

当我尝试插入 ActiveSheet.Range("H:H").Select 以使H列成为我的选择(这是我的目标)时,该代码将停止工作.

When I try inserting ActiveSheet.Range("H:H").Select to make column H my selection (which is my goal), the code stops working.

推荐答案

此代码在 Sheet1 中的 A1:A6 范围内找到了具有希腊欧元格式的单元格包含代码( ThisWorkbook )的工作簿.
单元格必须包含一个值(要查找空格,请将"*" 更改为" ).

This code found the cell with the Greek Euro format in the range A1:A6 on Sheet1 in the workbook containing the code (ThisWorkbook).
The cell must hold a value (to find blanks change "*" to "").

Sub Test()

    Dim rRangeToSearch As Range
    Dim rFoundRange As Range

    Set rRangeToSearch = ThisWorkbook.Worksheets("Sheet1").Range("A1:A6")

    Application.FindFormat.Clear
    Application.FindFormat.NumberFormat = "#,##0.00 [$€-408]"
    Set rFoundRange = rRangeToSearch.Find(What:="*", SearchFormat:=True)

    If Not rFoundRange Is Nothing Then
        MsgBox "Greek Euro format found in cell " & rFoundRange.Address
    End If

End Sub

不知道为什么 [$€-408] 表示希腊语.

No idea why [$€-408] denotes Greek.

这篇关于在代码定义的范围内搜索€符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 06:03
查看更多