简体   繁体   English

Excel 宏更改单元格中的字体

[英]Excel Macro to change font in cell

I need a macro that will in my spreadsheet search for:我需要一个可以在我的电子表格中搜索的宏:

  1. In Colum B: find a cell that contains "H1 or H2 or H3 or H4"在 B 列中:找到包含“H1 或 H2 或 H3 或 H4”的单元格
  2. then when found, change the font to bold and underline in the text in Column A然后找到后,将字体更改为粗体并在 A 列中的文本中加下划线

You should first answer these types of questions by using record macro.您应该首先使用记录宏来回答这些类型的问题。

Dim LastRow As Long
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row

For I = 0 to LastRow
If Cells(I, 2).Value = "H2" OR If Cells(I, 2).Value = "H3" Then 
Cells(I, 2).Font.Bold = True 'Probably doesnt work search the syntax 
End If
Next I



There are mistake i think but the structure is something like this我认为有错误,但结构是这样的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM