我有一个脚本可以更改单元格颜色和脚本以隐藏未着色的单元格。隐藏脚本有效,但它隐藏了 ALL 单元格,甚至是彩色单元格。我注意到当我使用更改单元格颜色的脚本时,不检测到excel界面中的更改(在'填充颜色'设置中' Home& #39;标签,在'字体大小'选择下)。我还注意到,当尝试更改使用脚本着色的单元格(使用excel接口)时,它不会更改(颜色似乎固定为从脚本设置的任何颜色)。
因此,界面似乎没有检测到使用着色脚本所做的更改。
另外,我注意到下面的脚本需要一段时间来检查/隐藏所有单元格。如果有办法加快这个过程,那就太好了!
任何帮助将不胜感激!
谢谢!
隐藏未着色单元格的脚本:
Public Sub HideUncoloredRows()
Dim startColumn As Integer
Dim startRow As Integer
Dim totalRows As Integer
Dim totalColumns As Integer
Dim currentColumn As Integer
Dim currentRow As Integer
Dim shouldHideRow As Integer
startColumn = 1 'column A
startRow = 1 'row 1
totalRows = Sheet1.Cells(Rows.Count, startColumn).End(xlUp).Row
For currentRow = totalRows To startRow Step -1
shouldHideRow = True
totalColumns = Sheet2.Cells(currentRow, Columns.Count).End(xlToLeft).Column
'for each column in the current row, check the cell color
For currentColumn = startColumn To totalColumns
'if any colored cell is found, don't hide the row and move on to next row
If Not Sheet1.Cells(currentRow, currentColumn).Interior.ColorIndex = -4142 Then
shouldHideRow = False
Exit For
End If
Next
If shouldHideRow Then
'drop into here if all cells in a row were white
Sheet2.Cells(currentRow, currentColumn).EntireRow.Hidden = True
End If
Next
End Sub
更改某些单元格颜色的脚本:
Range("A8").Select
Application.CutCopyMode = False
Range("A8").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF(Name_Preps,A8)=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3 'Changes the cell to green
.TintAndShade = 0.4
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
答案 0 :(得分:0)
尝试改变您的状况
For currentColumn = startColumn To totalColumns
'if any colored cell is found, don't hide the row and move on to next row
If Sheet1.Cells(currentRow, currentColumn).Interior.ThemeColor = xlThemeColorAccent3 Then
shouldHideRow = False
Exit For
End If
Next
答案 1 :(得分:0)
{<1}}等
未检测到条件格式设置如果你想继续这样做,你可以看到here或here了解相关代码
但我放弃了条件格式以及<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UpcomingCycleFragment"
android:padding="5dp"
android:id="@+id/upCycleFrag">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:layout_margin="3dp"
android:gravity="center"
android:id="@+id/upcomingTime"
android:text="--:-- AM"
android:textSize="15pt"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/upcomingDuration"
android:text="0m long"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/upcomingEnd"
android:text="Ends at --:--pm"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="right|center_vertical"
android:id="@+id/thisbuttonsucks"
android:text="Edit Time"
/>
</LinearLayout>
</FrameLayout>
/ Interior.ColorIndex
/ Select
/ Selection
模式,只需这样:
Activate