Beginner Macro Question

secox

New Member
Joined
Sep 30, 2004
Messages
13
I need to set a series of cells to a certain value by changing another serices of cells.

I know I can write a macro like:

Range("G53").GoalSeek Goal:=60000, ChangingCell:=Range("G61")
Range("H53").GoalSeek Goal:=60000, ChangingCell:=Range("H61")
Range("I53").GoalSeek Goal:=60000, ChangingCell:=Range("I61")
Range("J53").GoalSeek Goal:=60000, ChangingCell:=Range("J61")
Range("K53").GoalSeek Goal:=60000, ChangingCell:=Range("K61")
Range("L53").GoalSeek Goal:=60000, ChangingCell:=Range("L61")
Range("m53").GoalSeek Goal:=60000, ChangingCell:=Range("m61")

and so on, but I also know there is a way to do this in one step--I just don't know how. Can anyone tell me how to do this from Column G to Column BP without repeating each line?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

OdinsDream

Well-known Member
Joined
May 19, 2002
Messages
541
You mean like a loop?

Code:
CurrentColumn = 7 ' Column G
LastColumn = 68 ' Column BP

Do Until CurrentColumn > LastColumn
    Cells(53, CurrentColumn).GoalSeek Goal:=60000, ChangingCell:=Cells(61, CurrentColumn)
    CurrentColumn = CurrentColumn + 1
Loop
 

secox

New Member
Joined
Sep 30, 2004
Messages
13
That was what I was going for. I'll try changing it to something like that.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,703
Messages
5,855,242
Members
431,716
Latest member
Ibyb

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
Top