Help to translate the code

yichuansancun

Board Regular
Joined
Feb 7, 2011
Messages
123
Hello -

Can someone help me to interpret the following codes? Someone added this to my existing excel file in which I have already some codes in, but ever since the following codes were added, I am getting running time error by hiding row J to the very last row. Now sure if that has something to do with these codes:


Sub Macro1()
'
' Macro1 Macro
'

'
Range("G24").Select
Sheets("Local Plus Report").Select
ActiveWindow.LargeScroll Down:=-1
Range("G24").Select
ActiveCell.FormulaR1C1 = "=IF(R22C7=0,0,R[-20]C[7]-R[-20]C[8])"
Range("O3").Select
ActiveCell.FormulaR1C1 = "100000"
Range("O4").Select
Sheets("Local Plus Report").Select
Range("G25").Select
ActiveCell.FormulaR1C1 = "=IF(R22C7=0,0,R[-20]C[7]-R[-20]C[8])"
Range("G26").Select
ActiveCell.FormulaR1C1 = "=IF(R22C7=0,0,R[-20]C[7]-R[-20]C[8])"
Range("K7").Select
ActiveWorkbook.Save
Sheets("Home housing").Select
Sheets("United States local").Visible = True
Sheets("Local Plus Report").Select
Range("G26").Select
ActiveWorkbook.Save
End Sub


thanks,
Perri
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Doubt if it is causing your error unless your original code is calling macro1. If nothing is making it run then its not going to error.

Try clicking debug on the next error and see where the problem is.

Hidden columns don't usually cause a problem

ziggy
 
Upvote 0
you are right, these codes didn't do anything in fact, but I am getting the following error with my other codes:

running time error 1004: reference is not valid

here are the codes:

Sub Goalseek123()

Application.EnableEvents = False

Dim Previous As Range
Set Previous = ActiveCell

If LCase(Range("education_selection").Value) Like "*mercer data*" Then
Range("education").ClearContents
End If

If LCase(Range("choice").Value) Like "*specified amount*" Then
Range("housing_selection").ClearContents
ElseIf LCase(Range("choice").Value) Like "*mercer data*" Then
Range("housing").ClearContents
End If

Range("$N$7").Select
Range("$N$7").Goalseek Goal:=Range("$N$9").Value, ChangingCell:=Range("$N$3")

Range("$O$7").Select
Range("$O$7").Goalseek Goal:=Range("$O$9").Value, ChangingCell:=Range("$O$3")

Application.Goto Previous

Application.EnableEvents = True

End Sub


After I click "debug" the following line is highlighted:
Range("$N$7").Goalseek Goal:=Range("$N$9").Value, ChangingCell:=Range("$N$3")

know why? :confused:
 
Upvote 0
Check the contents of the cells listed. There might be some text or a formula in one of them.

Maybe try using goal seek manually in the data menu on the same cells to see what happens. It might come up with the error.

ziggy
 
Upvote 0
Here is what is happening:

this file is password protected and column J+ are hidden.

When I open this file, if I would unprotect the file and unhide the columns, then the macro is run with no error.

However, when I open this file, and run the macro next (without unprotect and unhide), the error appears.

:confused:
 
Upvote 0
That's because its trying to goal seek on a protected worksheet.

At the start of your code after the sub... add activesheet.unprotect before the end sub add activesheet.protect
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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