2016-07-05 1 views
0

2つのExcelシートがあり、30の列のうち6つにデータバーがあります。それらはすべて以下のものと同じコードを使用します。Excel Databarには表示されません。

しかし、いずれかのシートの2つの列には、データバーが表示されません。条件付き書式設定でルールを管理すると、そこにデータバーが表示されます。

次に、製品、地域などの異なるソートに基づいて、そのシートからいくつかのファイルを作成します。これらのファイルもデータバーを一貫して表示しません。

Windows 7 64ビット版Excel 2010 32ビット版を使用しています。

私は間違っていますか?あなたの助けを前にありがとう。

Public Function formatDatabar(wbkO As Workbook, wks As Worksheet, colNo As Integer) 

Dim i As Integer, ctr As Integer, col As Integer 

wbkO.Activate 
Set wks = wbkO.Worksheets(wks.Name) 
wks.Activate 
ctr = findLastRow(wks.Name) 
col = findLastCol(wks.Name) 

wbkO.Activate 
wks.Activate 
wks.Range(wks.Cells(5, 1), wks.Cells(ctr, col)).Select 

With Selection 
    .Cells.Font.Size = "8" 
    .Cells.Font.Bold = False 
    .Cells.Font.Name = "Calibri" 
    .VerticalAlignment = xlCenter 
End With 

wks.Range(wks.Cells(5, colNo), wks.Cells(ctr, colNo)).Select 

Selection.FormatConditions.AddDatabar 
Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True 
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority 
With Selection.FormatConditions(1) 
    .MinPoint.Modify newtype:=xlConditionValueAutomaticMin 
    .MaxPoint.Modify newtype:=xlConditionValueAutomaticMax 
End With 
With Selection.FormatConditions(1).BarColor 
    .ThemeColor = xlThemeColorAccent6 
    .TintAndShade = 0.13012579 
End With 
Selection.FormatConditions(1).BarFillType = xlDataBarFillGradient 
Selection.FormatConditions(1).Direction = xlContext 
Selection.FormatConditions(1).NegativeBarFormat.ColorType = xlDataBarColor 
Selection.FormatConditions(1).BarBorder.Type = xlDataBarBorderSolid 
Selection.FormatConditions(1).NegativeBarFormat.BorderColorType = _ 
    xlDataBarColor 
With Selection.FormatConditions(1).BarBorder.Color 
    .ThemeColor = xlThemeColorAccent6 
    .TintAndShade = 0.13012579 
End With 
Selection.FormatConditions(1).AxisPosition = xlDataBarAxisAutomatic 
With Selection.FormatConditions(1).AxisColor 
    .Color = 0 
    .TintAndShade = 0 
End With 
With Selection.FormatConditions(1).NegativeBarFormat.Color 
    .Color = 255 
    .TintAndShade = 0 
End With 
With Selection.FormatConditions(1).NegativeBarFormat.BorderColor 
    .Color = 255 
    .TintAndShade = 0 
End With 

エンド機能

第二千四百七十二行で
+0

1)[選択を避ける](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros) 2)あなたには機能がありません。あなたにはサブがあります。関数は何らかの値を返します。 3)私はこの問題を、各セルについてこの関数を呼び出すコードに入れることができると思われますが、明白な理由で確実に言うのは難しいです。 –

+0

呼び出し関数は、さまざまな列の書式を設定し、この列を呼び出します。 call formatDatabar(wbkO、wks、35) – user3150378

+0

そして、選択範囲を完全修飾範囲参照に変更しましたが、それでも機能しません。私は、各セルがデータバーの相対的なサイズを持つためにループではなく範囲参照を使用する必要があります。 呼び出し元のメソッドは、やり直す前にすべての書式設定もクリアします。いずれにしても、シートは削除され、毎回再作成され、バックエンドからデータが移入されるため、残余書式に関する問題はないと思います。 – user3150378

答えて

0

、%は、他のすべてのほとんど何も作り、非常に高かったです。これにより、他のすべての行のデータバーが表示されなくなりました。

ありがとうございました。

関連する問題