Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
offset problems
Just when I thought I was getting better at using VBA I get stuck o
something that I'm sure should be simple :( : in my spreadsheet I have a macro called "addrow" which adds a bordere area of 6 rows and 7 columns to the bottom of the current table. Thi macro uses a cell named "insertpoint" so that it knows where to inser the copied area. The First area covers A2:G7, the second covers A8:G13 and so on. Eac existing area is numbered in it's second row, in column A (thus th A2:G7 area is numbered "1" in cell A3, the A8:G13 area is numbered "2 in cell A9 etc). All I want to know is, how do I modify the existing code t automatically enter this number in a newly added area? I know i should be a case of using offset to find the last used value and th cell in which to place this same value +1, but how??? The code so far is:- Sub addrow() ' Sheets("Row Template").Range("A1:G6").Copy Sheets("Quote").Range("insertpoint").Insert Shift:=xlDown Sheets("Quote").PageSetup.PrintArea "$A$1:(offset(insertpoint,1,6))" End Sub I think it should be change to something like:- Sub addrow() ' Sheets("Row Template").Range("A1:G6").Copy Sheets("Quote").Range("insertpoint").Insert Shift:=xlDown Sheets("Quote").offset(insertpoint,-5,0).value (offset(insertpoint,-11,0).value)+1 Sheets("Quote").PageSetup.PrintArea "$A$1:(offset(insertpoint,1,6))" End Sub ...but this produces the error "sub or function not defined". Am making a syntax error??? HELP -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
OFFSET Problems | Excel Worksheet Functions | |||
Offset/COUNTA problems | Excel Worksheet Functions | |||
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul | Excel Worksheet Functions | |||
Problems with offset/average formula | Excel Worksheet Functions | |||
Problems copying cells using offset and counta | Excel Discussion (Misc queries) |