Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default VBA to count rows from specific cell and insert rows

Within a macro I have a "found" cell (Find "US03" in certain column) which
can be on any row. I need code to count down 170 rows from this cell and
insert 2 rows. This is done from the top of the worksheet.

Thanks!!
Valerie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default VBA to count rows from specific cell and insert rows

not sure where you want to start, but this may give you an idea on how to do
what you want

Worksheets("Sheet1").Range("A1").Offset(170).Resiz e(2).EntireRow.Insert

--


Gary


"Valerie" wrote in message
...
Within a macro I have a "found" cell (Find "US03" in certain column) which
can be on any row. I need code to count down 170 rows from this cell and
insert 2 rows. This is done from the top of the worksheet.

Thanks!!
Valerie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default VBA to count rows from specific cell and insert rows

Hi,
try something like

DIm rg as range

''' where to search
set rg=activesheet.range("U:U")
''' search for 'found'
set rg=rg.find(what:="found", lookin:=xlvalues, lookat:=xlwhole)
''' process result
if rg is nothing then ''' was not fond
msgbox "Not found"
else
''' go 170 rows bellow that found cell
set rg=rg.offset(170)
''' resize to 2 rows
set rg= rg.resize(2)
''' insert 2 rows
rg.EntireRow.Insert xlShiftDown
end if

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Valerie" wrote:

Within a macro I have a "found" cell (Find "US03" in certain column) which
can be on any row. I need code to count down 170 rows from this cell and
insert 2 rows. This is done from the top of the worksheet.

Thanks!!
Valerie

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default VBA to count rows from specific cell and insert rows

Works like a charm!! Thanks!!

"sebastienm" wrote:

Hi,
try something like

DIm rg as range

''' where to search
set rg=activesheet.range("U:U")
''' search for 'found'
set rg=rg.find(what:="found", lookin:=xlvalues, lookat:=xlwhole)
''' process result
if rg is nothing then ''' was not fond
msgbox "Not found"
else
''' go 170 rows bellow that found cell
set rg=rg.offset(170)
''' resize to 2 rows
set rg= rg.resize(2)
''' insert 2 rows
rg.EntireRow.Insert xlShiftDown
end if

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Valerie" wrote:

Within a macro I have a "found" cell (Find "US03" in certain column) which
can be on any row. I need code to count down 170 rows from this cell and
insert 2 rows. This is done from the top of the worksheet.

Thanks!!
Valerie

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 do i count and insert rows calvin Excel Discussion (Misc queries) 3 May 14th 09 08:21 PM
Insert rows based on specific value bob Excel Worksheet Functions 6 February 29th 08 07:11 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM
Count rows with specific attributes in VBA Steve Newhouse Excel Worksheet Functions 3 February 25th 06 01:30 AM
Count rows with specific date lakegoddess Excel Discussion (Misc queries) 3 August 9th 05 04:36 PM


All times are GMT +1. The time now is 01:40 AM.

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"