Excel vill inte uppdatera automatiskt med macro

Medlem
Excel vill inte uppdatera automatiskt med macro

Tjena

Sitter och skapar en Excel på jobb där jag använder mig av ett macro:
Function GetCellColor(xlRange As Range)
Dim indRow, indColumn As Long
Dim arResults()

Application.Volatile

If xlRange Is Nothing Then
Set xlRange = Application.ThisCell
End If

If xlRange.Count > 1 Then
ReDim arResults(1 To xlRange.Rows.Count, 1 To xlRange.Columns.Count)
For indRow = 1 To xlRange.Rows.Count
For indColumn = 1 To xlRange.Columns.Count
arResults(indRow, indColumn) = xlRange(indRow, indColumn).Interior.Color
Next
Next
GetCellColor = arResults
Else
GetCellColor = xlRange.Interior.Color
End If
End Function

Function CountCellsByColor(rData As Range, cellRefColor As Range) As Long
Dim indRefColor As Long
Dim cellCurrent As Range
Dim cntRes As Long

Application.Volatile
cntRes = 0
indRefColor = cellRefColor.Cells(1, 1).Interior.Color
For Each cellCurrent In rData
If indRefColor = cellCurrent.Interior.Color Then
cntRes = cntRes + 1
End If
Next cellCurrent

CountCellsByColor = cntRes
End Function

Problemet är att resultet inte uppdateras automatiskt
Har en formel i dokumentet som ser ut så här:
=CountCellsByColor($B$3:$Q$3;W3)
Där W3 är en bestämd färg, sedan sedan från den har jag länkat SUMMA till en annan ruta. Men den rutan som jag har koden ovan uppdaterar inte automatiskt då jag fyller i en färg mellan B3 och Q3 utan jag får gå till rutan och trycka Retur för att uppdatera summan av koden för att den sedan skall uppdatera SUMMA.

Varför uppdaterar inte excel automatiskt för? Filen är en macro (xslm)

Medlem
Skrivet av delli:

Tjena

Sitter och skapar en Excel på jobb där jag använder mig av ett macro:
Function GetCellColor(xlRange As Range)
Dim indRow, indColumn As Long
Dim arResults()

Application.Volatile

If xlRange Is Nothing Then
Set xlRange = Application.ThisCell
End If

If xlRange.Count > 1 Then
ReDim arResults(1 To xlRange.Rows.Count, 1 To xlRange.Columns.Count)
For indRow = 1 To xlRange.Rows.Count
For indColumn = 1 To xlRange.Columns.Count
arResults(indRow, indColumn) = xlRange(indRow, indColumn).Interior.Color
Next
Next
GetCellColor = arResults
Else
GetCellColor = xlRange.Interior.Color
End If
End Function

Function CountCellsByColor(rData As Range, cellRefColor As Range) As Long
Dim indRefColor As Long
Dim cellCurrent As Range
Dim cntRes As Long

Application.Volatile
cntRes = 0
indRefColor = cellRefColor.Cells(1, 1).Interior.Color
For Each cellCurrent In rData
If indRefColor = cellCurrent.Interior.Color Then
cntRes = cntRes + 1
End If
Next cellCurrent

CountCellsByColor = cntRes
End Function

Problemet är att resultet inte uppdateras automatiskt
Har en formel i dokumentet som ser ut så här:
=CountCellsByColor($B$3:$Q$3;W3)
Där W3 är en bestämd färg, sedan sedan från den har jag länkat SUMMA till en annan ruta. Men den rutan som jag har koden ovan uppdaterar inte automatiskt då jag fyller i en färg mellan B3 och Q3 utan jag får gå till rutan och trycka Retur för att uppdatera summan av koden för att den sedan skall uppdatera SUMMA.

Varför uppdaterar inte excel automatiskt för? Filen är en macro (xslm)

"When Excel formulas are not updating automatically, most likely it's because the Calculation setting has been changed to Manual instead of Automatic. To fix this, just set the Calculation option to Automatic again"

Medlem
Skrivet av noyart:

"When Excel formulas are not updating automatically, most likely it's because the Calculation setting has been changed to Manual instead of Automatic. To fix this, just set the Calculation option to Automatic again"

Tack för tipset men har den på automatiskt så får helt enkelt köra med siffror istället även om jag velat ha beräkningen på färg istället eftersom det är en "mätare" som går från 0 - 100 %

Medlem

Har du frågat på Sweclockers? Känns som det kanske är större chans att få svar där.


signatur

PSN: OAKTHYR

1
Skriv svar