Can Someone Adjust These VB Codes PLEASE...

Mister H

Well-known Member
Joined
Mar 6, 2002
Messages
1,507
Hi:

I am new to VB and quite unfamiliar with the different commands. I am using the following code and was wondering if it could be adjusted.


Code:
Sub RestoreDepositForm()
                  
' (FINAL)

Answer = MsgBox("WARNING!  Do you really want to Restore The Deposit Form?" & vbCr & vbCr & "Doing so will DELETE the current Deposit Form and ALL its data.", vbOKCancel, "WARNING!")

If Answer = vbCancel Then Exit Sub

If Answer = vbOK Then

If Answer2 = vbCancel Then Exit Sub
End If


End Sub

What I want it to do is if the person clicks OK 9to delete) thean I want it to take them to cell " C3 " on the " Control Log " sheet

The other problem I am having with a code that was created (via macro) is that when I save my workbook with a diffeerent name it no longer functions.
Sub PrepareBankSummarySheet()
'
' PrepareBankSummarySheet Macro
' Macro recorded 29/11/2005 (FINAL)
'

'
Range("F30").Select
Application.Run "'Nov 29th FINAL.xls'!ShowAllBankSummaryData"
Range("A2:C401").Select
Selection.FillDown
ActiveWindow.ScrollRow = 1
Range("A2").Select
Application.Run "'Nov 29th FINAL.xls'!HideBankSummaryData"
End Sub

Can this be tweaked to remain functional regardless of the Workbook Name? I know I probably need to replace the Nov 29th FINAL with something else I am just not sure what.

As ALWAYS, THANKS to anyone that can assist.

Bye 4 Now,
Mark
Sudbury, Ontario
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
For your first question:

Code:
Sub RestoreDepositForm() 
                  
' (FINAL) 

Answer = MsgBox("WARNING!  Do you really want to Restore The Deposit Form?" & vbCr & vbCr & "Doing so will DELETE the current Deposit Form and ALL its data.", vbOKCancel, "WARNING!") 

If Answer = vbCancel Then Exit Sub 

If Answer = vbOK Then 
   Application.Goto Worksheets("Control Log").Range("C3") 
End If 

End Sub

For your second question where is the Sub PrepareBankSummarySheet and what does it do?
 
Upvote 0
If you want the workbook with the macro in it use ThisWorkbook, otherwise ActiveWorkBook. eg.

Code:
'cell " C3 " on the " Control Log " sheet
Application.Goto 
    reference:=ThisWorkbook.Worksheets("Control log").Range("C3"), _
    Scroll:=True
 
Upvote 0
Hi Andrew:

THANKS... In regards to your question the I am not sure what you mean. The Macro Button is located on the "Bank Summary" sheet and what it is supose to do:

Show All Rows (unfilter)
Copy Formulas down from Row 2 to 400
Hide Blank Rows (filter)

As mentioned this works fine until I renmae the book and close the original book. Once I open the newly named workbook the macro no longer works. Hoep this helps. Sorry for the confusion.

Take Care,
Mark
 
Upvote 0
Hi Andrew:

Yes it is one workbook. The workbook contains 7 seperate sheets one of which is "Control Log". I want to be able to send this workbook to multiple users who in turn will rename the book whenever they use it which is why I need the macro (code) to work regardless of the name of the workbook. Hope this clarifies things (a little?).

Bye 4 now,
Mark. :p
 
Upvote 0
Code:
Sub PrepareBankSummarySheet() 
' 
' PrepareBankSummarySheet Macro 
' Macro recorded 29/11/2005 (FINAL) 
' 

' 
Range("F30").Select 
Application.Run "'Nov 29th FINAL.xls'!ShowAllBankSummaryData" 
Range("A2:C401").Select 
Selection.FillDown 
ActiveWindow.ScrollRow = 1 
Range("A2").Select 
Application.Run "'Nov 29th FINAL.xls'!HideBankSummaryData" 
End Sub 


[quote]So all you need is: 

Call ShowAllBankSummaryData

Sorry for the confusion but do I just delete the wording:

"'Nov 29th FINAL.xls'!HideBankSummarData" and replace it with

"HideBankSummaryData"

THANKS for your help.[/quote]
 
Upvote 0
Hi Andrew:

THANKS... I should have experimented BEFORE I sent you the last post. I have now fixed the problem THANKS to your solution.

Have a GREAT day,
Mark
 
Upvote 0

Forum statistics

Threads
1,203,515
Messages
6,055,844
Members
444,828
Latest member
StaffordStag

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top