C
Casey
Hi,
I have sheet that imports data from another sheet via a comand button
The sheet also has two option buttons. What I am attempting to do i
import slighty different information from the other sheet depending o
which optionbutton is selected. (There is code behind the optio
buttons to insure only one can be chosen at a time.)
I am getting the following error message:
Compile Error:
Method or Data Member not found.
This is a new error message for me and nothing in Help is given me an
more ideas to try.
Here is my Code:
Option Explicit
Sub Import_CWR_SUBCON_COSTS_To_SubConCO()
Dim Wks1 As Worksheet
Dim Wks3 As Worksheet
Dim CopyRow As Long
Dim Entries As Long
Dim i As Long
Dim N As Long
Dim Cnt As Integer
Dim Msg As Integer
Dim Response As Integer
Dim OptionButton1 As Object '<<<<<<<<< Not sure this is correct
Dim OptionButton2 As Object '<<<<<<<<< Not sure this is correct
Dim Opt1 As Boolean
Dim Opt2 As Boolean
Msg = MsgBox("Have you double checked the SUB CO NO: and that the sam
SUB CO NO:" _
& " has been entered in the appropriate cell of the CWR Log for each
_
& " CWR you want to make part of this Subcontractor Change Order ?", _
vbYesNo + vbQuestion, "Import CWRs to Subcontractor Change Order by SU
CO NO:")
If Msg = 6 Then
Application.ScreenUpdating = False
Set Wks1 = Worksheets("CWR LOG")
Set Wks3 = ActiveSheet
Opt1 = Wks3.OptionButton1.Value '<<<<<<<Compile Error
Opt2 = Wks3.OptionButton2.Value '<<<<<<<Compile Error
Wks3.Range("SubCon_Entry_Range").ClearContents
CopyRow = 30
Entries = Excel.WorksheetFunction.CountA(Wks1.Range("B:B"))
Cnt = 0
For i = 9 To Entries + 100
N = Wks1.Cells(i, 2).Value
If N = Range("SubCon_CHANGE_ORDER_NO") Then Cnt = Cnt + 1
If Cnt > 15 Then
Msg = MsgBox("You are attempting to import more than 15 CW
records. Only the First 15 Records will be pasted. Please return to th
CWR Log Page and reduce the number of CWRs you want to make part o
this Change Order to 15 or less. Then hit the Import Subcontracto
Costs from CWR's button again.", vbOKOnly + vbCritical, "Exceede
number of Records")
If Response = 1 Or 2 Then
Exit Sub
End If
ElseIf N = Range("SubCon_CHANGE_ORDER_NO") And Cnt <= 15 _
And Opt1 = True Then
With Wks3
.Unprotect ("geekk")
.Cells(CopyRow, 2).Value = Wks1.Cells(i, 3).Value
.Cells(CopyRow, 3).Value = Wks1.Cells(i, 1).Value
.Cells(CopyRow, 4).Value = Wks1.Cells(i, 4).Value
.Cells(CopyRow, 5).Value = Wks1.Cells(i, 6).Value
.Protect ("geekk")
End With
CopyRow = CopyRow + 1
ElseIf N = Range("SubCon_CHANGE_ORDER_NO") And Cnt <= 15 _
And Opt2 = True Then
With Wks3
.Unprotect ("geekk")
.Cells(CopyRow, 2).Value = Wks1.Cells(i, 3).Value
.Cells(CopyRow, 3).Value = Wks1.Cells(i, 1).Value
.Cells(CopyRow, 4).Value = Wks1.Cells(i, 4).Value
.Cells(CopyRow, 5).Value = Wks1.Cells(i, 7).Value
.Protect ("geekk")
End With
CopyRow = CopyRow + 1
End If
Next i
Wks3.Range("L5").Activate
Application.ScreenUpdating = True
End If
If Msg = 7 Then
Exit Sub
End If
End Su
I have sheet that imports data from another sheet via a comand button
The sheet also has two option buttons. What I am attempting to do i
import slighty different information from the other sheet depending o
which optionbutton is selected. (There is code behind the optio
buttons to insure only one can be chosen at a time.)
I am getting the following error message:
Compile Error:
Method or Data Member not found.
This is a new error message for me and nothing in Help is given me an
more ideas to try.
Here is my Code:
Option Explicit
Sub Import_CWR_SUBCON_COSTS_To_SubConCO()
Dim Wks1 As Worksheet
Dim Wks3 As Worksheet
Dim CopyRow As Long
Dim Entries As Long
Dim i As Long
Dim N As Long
Dim Cnt As Integer
Dim Msg As Integer
Dim Response As Integer
Dim OptionButton1 As Object '<<<<<<<<< Not sure this is correct
Dim OptionButton2 As Object '<<<<<<<<< Not sure this is correct
Dim Opt1 As Boolean
Dim Opt2 As Boolean
Msg = MsgBox("Have you double checked the SUB CO NO: and that the sam
SUB CO NO:" _
& " has been entered in the appropriate cell of the CWR Log for each
_
& " CWR you want to make part of this Subcontractor Change Order ?", _
vbYesNo + vbQuestion, "Import CWRs to Subcontractor Change Order by SU
CO NO:")
If Msg = 6 Then
Application.ScreenUpdating = False
Set Wks1 = Worksheets("CWR LOG")
Set Wks3 = ActiveSheet
Opt1 = Wks3.OptionButton1.Value '<<<<<<<Compile Error
Opt2 = Wks3.OptionButton2.Value '<<<<<<<Compile Error
Wks3.Range("SubCon_Entry_Range").ClearContents
CopyRow = 30
Entries = Excel.WorksheetFunction.CountA(Wks1.Range("B:B"))
Cnt = 0
For i = 9 To Entries + 100
N = Wks1.Cells(i, 2).Value
If N = Range("SubCon_CHANGE_ORDER_NO") Then Cnt = Cnt + 1
If Cnt > 15 Then
Msg = MsgBox("You are attempting to import more than 15 CW
records. Only the First 15 Records will be pasted. Please return to th
CWR Log Page and reduce the number of CWRs you want to make part o
this Change Order to 15 or less. Then hit the Import Subcontracto
Costs from CWR's button again.", vbOKOnly + vbCritical, "Exceede
number of Records")
If Response = 1 Or 2 Then
Exit Sub
End If
ElseIf N = Range("SubCon_CHANGE_ORDER_NO") And Cnt <= 15 _
And Opt1 = True Then
With Wks3
.Unprotect ("geekk")
.Cells(CopyRow, 2).Value = Wks1.Cells(i, 3).Value
.Cells(CopyRow, 3).Value = Wks1.Cells(i, 1).Value
.Cells(CopyRow, 4).Value = Wks1.Cells(i, 4).Value
.Cells(CopyRow, 5).Value = Wks1.Cells(i, 6).Value
.Protect ("geekk")
End With
CopyRow = CopyRow + 1
ElseIf N = Range("SubCon_CHANGE_ORDER_NO") And Cnt <= 15 _
And Opt2 = True Then
With Wks3
.Unprotect ("geekk")
.Cells(CopyRow, 2).Value = Wks1.Cells(i, 3).Value
.Cells(CopyRow, 3).Value = Wks1.Cells(i, 1).Value
.Cells(CopyRow, 4).Value = Wks1.Cells(i, 4).Value
.Cells(CopyRow, 5).Value = Wks1.Cells(i, 7).Value
.Protect ("geekk")
End With
CopyRow = CopyRow + 1
End If
Next i
Wks3.Range("L5").Activate
Application.ScreenUpdating = True
End If
If Msg = 7 Then
Exit Sub
End If
End Su