Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Macro to input formula in range based on another range

Try this - make sure that the names column is selected
before it is run. It assumes that the range starts in row
1 with the data in row 2.

Sub fillFormulas()
Dim rng As Range
Dim i As Integer, r As Integer

'activecell should be in the names column
r = ActiveCell.CurrentRegion.Rows.Count
col = ActiveCell.Column
For i = 2 To r
Cells(i, col + 1).Formula = "=SUM(RC[-6]:RC[-2])"
Next i
End Sub

Regards
Peter
-----Original Message-----
Hi folks, here is my problem. I have a column of names

(may be in any
column depending on the workbook, but lets assume col B)

with an empty
column to the right of it(col C) .

I want to write a macro that will input a formula in each

cell of
column C if there is a name in the corresponding cell of

col B. There
will be no blank cells in col B so the first blank cell

will be at the
end of the list and should stop the macro.

Can anyone help with some code ideas? Thanks.:)



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
extract data from a range based on other cell's input Snooky Excel Discussion (Misc queries) 1 May 18th 08 10:06 PM
List Box - For Input Range can I use named range in another workbo dim Excel Worksheet Functions 2 January 3rd 08 06:10 PM
Macro to insert a formula based on a range MarcusA Excel Discussion (Misc queries) 1 December 8th 06 09:26 AM
Trying to select a specific range based on the time value of user form input Jitranijam New Users to Excel 8 November 15th 06 12:52 AM
Select cell from range based on input in excel xp dingy101 Excel Discussion (Misc queries) 3 November 20th 05 12:05 AM


All times are GMT +1. The time now is 03:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"