View Full Version : VBA help
John84
11-24-2008, 11:25 AM
I have a working VBA that I use for one tab in a large workbook. Its just a simple goalseek. However I'm trying to find a way to run the program while working on another sheet. If I use a shortcut, the VBA is runs on the working tab. Is there a way to restrict a VBA to a specific tab? I appreciate any help.
Bob Phillips
11-24-2008, 11:36 AM
Refer to the worksheet directy
With Worksheets("sheet_name")
'dot qualified properties/methods
End With
John84
11-24-2008, 11:45 AM
I appreciate the quick response. So my macro looks like this (should have put this in orginally):
Sub Equivelent_Section()
'
' Equivelent_Section Macro
'
'
Range("Q36").Select
Range("Q36").GoalSeek Goal:=0, ChangingCell:=Range("C34")
End Sub
And I want to use it only in a sheet called "Comp Sect. Prop."
Where would I place your add-in. Again I really appreciate your help
Bob Phillips
11-24-2008, 11:47 AM
Sub Equivelent_Section()
'
' Equivelent_Section Macro
'
'
With "Comp Sect. Prop."
.Range("Q36").Select
.Range("Q36").GoalSeek Goal:=0, ChangingCell:=.Range("C34")
End With
End Sub
John84
11-24-2008, 12:27 PM
I copied over the new VBA but I am getting a "compile error". The debugger highlights "With" and says "With object must be user-defined type, object, or Variant". I'm not too sure on what that means.
Bob Phillips
11-24-2008, 12:59 PM
Sorry, I was having problems with that post and messed up
Sub Equivelent_Section()
'
' Equivelent_Section Macro
'
'
With Worksheets("Comp Sect. Prop." )
.Range("Q36").Select
.Range("Q36").GoalSeek Goal:=0, ChangingCell:=.Range("C34")
End With
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.