|
▼学生 さん:
こんばんは。
これね、テスト問題だとしたら
結構、難しい問題ですよ!!
だって、
・プログラムの仕様はわからない
・アルゴリズムが正しいのかもわからない
まず、下のコードが何をしてくれるコードなのか
記述して下さい。
この時、文章だけでは伝わらない又は、わかりづらいと思ったら、
具体例を挙げて記述して下さい。
> Application.Workbooks(bookname).Select
>が黄色のラインがかかってしまうのですが…。
これは、WorkbookオブジェクトにSelectというメソッドがないからです。
Activateに変えてみてください。
他にもありそうですが・・・。
>
>Sub Q4()
>Dim mydata() As Variant
>Dim bookname As String, newbookname As String, i As Integer
>Dim j As Integer, a As Integer, z As Integer, y As Integer, NoSheets As Integer
>
> bookname = InputBox("Please inter data workbook's name")
> Application.Workbooks.Open (bookname)
>
> NoSheets = Application.Worksheets.Count
> 'MsgBox NoSheets
>
> Application.SheetsInNewWorkbook = 3
> Application.Workbooks.Add
> newbookname = InputBox("Please inter new workbook's name")
> ActiveWorkbook.SaveAs newbookname
>
>
> Application.Workbooks(bookname).Select
>
>Dim DataArray() As Variant
>Dim Counter As Integer
>'Dim NoSheets As Integer
>Dim RowNo As Integer
>Dim ColNo As Integer
>Dim Address As String
>Dim StringNo As Integer
>Dim NumNo As Integer, sum As Variant
>'Dim a As Integer, z As Integer, y As Integer
>
>RowNo = 1
>ColNo = 1
>Address = "R" & RowNo & "C" & ColNo
>
>Application.Workbooks.Add
>
>NoSheets = Application.Worksheets.Count
>
>ReDim DataArray(1 To NoSheets)
>
>For Counter = 1 To NoSheets
>
> DataArray(Counter) = Application.Worksheets(Counter).Cells(RowNo, ColNo).Value
> ' You cannot use Range because it is confined to an A1 address style
>
> If TypeName(DataArray(Counter)) = "String" Then
> StringNo = StringNo + 1
> End If
>
> If IsNumeric(DataArray(Counter)) Then
> NumNo = NumNo + 1
> End If
>
> ' Code for sum in Summary sheet goes here
> ReDim mydata(1 To 10, 1 To 10) As Variant
> For z = 1 To 10
> For y = 1 To 10
> 'For a = 1 To NoSheets
> Sheets(Counter).Select
> mydata(z, y) = Sheets(Counter).Cells(z, y).Value
> sum = mydata(z, y) + Sheets(Counter).Cells(z, y).Value
> 'Next a
> Next y
> Next z
>
> Application.Workbooks(newbookname).Selected
> Cells(z, y) = sum
>
> If NumNo = 0 Then Cells(z, y) = "No Data"
>
>Next Counter
>
>
>End Sub
|
|