Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VB macros & "relative positioning"

Dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.columns(1).insert
.range("A1:A" & lastrow).FormulaR1C1 = "=IF(RC[1]<25,1,0)"
end with

And personally, I like to use excel's built in Data|subtotals whenever
possible. If I have to add a formula to put an identifier on that row, that's
ok with me, too.

Jennifer wrote:

I want to write a VB macro that will insert a column at the beginning of the
spreadsheet, add a formula that deals with another cell on the same row, and
then copy the formula for every row that has data in it. (Each row with data
will have data in the original column A). Because there may be a different
number of rows each time, I want to have the macro recognise relative
positioning (I think that's the correct term). Namely, if I can get to the
last row that has data, I want to move one cell to the right. However, when
I record the macro, it identifies a specific cell (in this case, cell A31.
Any suggestions?

Existing code:
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[1]<25,1,0)"
Range("A1").Select
Selection.Copy
Range("B1").Select
Selection.End(xlDown).Select
Range("A31").Activate
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Range("A1").Select

In addition, what I would ultimately like to do is to have the macro look at
the contents of each non-empty cell in (the original) column A to see if it
matches a specific work unit. (I have a table with all of the work units,
and have a formula which works using IF and MATCH). For each row identified
as being a work unit, I want to bold that row and add two rows above it, and
then add formulae (for totals) in the row above. Any hints how this could be
done?


--

Dave Peterson
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
How can I best "scrub" a wkbk of "phantom macros"? Dave Braden Excel Discussion (Misc queries) 5 January 4th 10 03:12 PM
"excel "macros may be disabled" message using an xlam file frustrated Excel Worksheet Functions 2 July 13th 09 08:32 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"openinf file..."ENABLE MACROS...DISABLE MACROS" F. Lawrence Kulchar Excel Discussion (Misc queries) 3 September 12th 06 10:33 AM
Change "relative" to "absolute" (database) Len Dolby[_2_] Excel Programming 4 November 3rd 03 05:36 PM


All times are GMT +1. The time now is 11:08 AM.

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

About Us

"It's about Microsoft Excel"