LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Use optionbutton value to select code to run.


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

--
Case

-----------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...nfo&userid=454
View this thread: http://www.excelforum.com/showthread.php?threadid=54075

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBa code to select from worksheet mike Excel Programming 2 March 31st 06 12:46 AM
VBA code to always select next available new workbook wayliff[_3_] Excel Programming 3 December 26th 05 05:01 PM
SendKeys command to select an OptionButton Fred Russell Excel Programming 6 August 6th 05 01:09 AM
How do I select this range using code....another try at it. TBA[_3_] Excel Programming 2 January 14th 04 11:13 PM
Code to Select Row David McRitchie[_2_] Excel Programming 0 September 19th 03 11:02 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"