0

テストによく似た形式の情報を含む Excel ワークシートがあります。

Choice     Chosen        Percentage
A 
B 
C 
D 
TOTAL 
False 
True 
TOTAL 

選択された列には、各選択肢が選択された回数が表示され、合計行には対応する質問の合計が表示されます。それぞれが選択されたパーセンテージ (選択済み/合計) をすばやく見つける方法が必要ですが、その方法がわかりません。

4

2 に答える 2

1

そのためにVBAは必要ないと思います。私が質問を理解していれば、それは単純な式です。これらがヘッダーであり、セル A1 から始まると仮定すると、列 b (選択は A) のパーセンテージは =B2/$F2 のようになり、列をパーセンテージ タイプとして書式設定します。

$F は F への絶対参照であるため、入力すると常に行 F (合計行) を指しますが、列番号は必要に応じて変更されます。

于 2010-11-02T21:23:02.100 に答える
0

私はその場でこのウィンドウ自体にコードを書いているので、エラーに注意する必要があります。また、疑似コードのコードを入れる必要があります

dim currRow as integer
dim frs as boolean
firstRow = 1
frs = false
range("A1").select
<loop over column A until you reach a blank value>
  If selection.value == "Choice" then 
    ' move to next row, nothing to see here
  else if not selection.value == "Total" then
    if frs = false then 
      firstRow = selection.row
      frs = true
    endif
  else if selection.value = "Total" then
    frs = false
    dim i as integer
    for i = firstRow to selection.row -1
      range("C" + cstr(i)).formula = "=B"+ cstr(1)+"/B" + cstr (selection.row) ' or something to that effect
    next
  end if
  Selection.cells(2,1).select ' selects the next cell vertically
end loop

「firstrow」が設定されたことを示すために frs を使用しています

于 2010-11-03T18:19:11.077 に答える