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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,309
Messages
5,641,448
Members
417,209
Latest member
Agbarker

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