【发布时间】:2018-05-07 01:14:27
【问题描述】:
编辑:我已经清理了代码,如下所示。我试图找到一种方法来执行代码,只需在偏移范围内的行中添加 1。这可能吗?? enter image description here
我想要完成的事情:
- 查找“工资 QRE Exp”列 一个。如果上述单元格与“Ref.”相邻。然后我想搜索他们的以下值
- 将宏应用于“QRE”列的灰色行之间的所有行。 一个。在左侧相邻单元格中填写页码引用 湾。直到单元格颜色 = Gray -25% (.ThemeColor = xlThemeColorDark2) 我相信
-
结束
Sub Find_Data() Dim datatoFind As String, MySheet As String, FV As String Dim aSh As Worksheet, fSh As Worksheet Dim firstResult As Range Dim secondResult As Range Dim rng As Range Dim LeftCell As Range Dim leftValue As String Set rng = Cells.Find(What:="Wage QRE Exp", after:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True, SearchFormat:=False) Set LeftCell = rng.Offset(0, -1) leftValue = LeftCell.Value If leftValue = "Ref." Then Set findValue = rng.Offset(1, 0) Set aSh = Sheet1 datatoFind = findValue sheetCount = ActiveWorkbook.Sheets.Count If Len(datatoFind) = 0 Or Not IsNumeric(datatoFind) Then Exit Sub For counter = 1 To sheetCount Sheets(counter).Activate Set firstResult = Cells.Find(What:=datatoFind, after:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True, SearchFormat:=False) Set secondResult = Cells.FindNext(after:=firstResult) Debug.Print secondResult.Address If Not firstResult Is Nothing Then MySheet = IIf(InStr(secondResult.Parent.Name, "."), Split(secondResult.Parent.Name, ".")(0), Split(secondResult.Parent.Name)(0)) FV = MySheet & "." & pageNum(secondResult) Else End If Next counter With rng.Offset(1, -1) .Value = FV .Font.Name = "Times New Roman" .Font.Bold = True .Font.Size = "10" .Font.Color = vbRed .HorizontalAlignment = xlRight .VerticalAlignment = xlCenter End With End If结束子
【问题讨论】:
-
这是什么意思?
Find Columns “Wage QRE Exp” a. If the above cell is left adjacent to “Ref.” then I want to search their below values -
插入工作表图像时,请确保行和列编号/字母可见。
-
dbmitch:我想在我的新图片中搜索显示为“Wage QRE Exp”的单元格,C4,并确保 B4 为 =“Ref”。但这已经在我当前的代码中解决了。现在我只需要它再次运行第 6 行及以后的宏。