Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Row insertion problem

I'm a newbie to VBA, have been teaching myself the past week, and I'
stuck on the last step of a complex macro I've been writing. What
want to do is insert a row (or more than one row in some cases
depending on the value returned by one column in the worksheet. Thi
function returns either 1, 2, or 3 for each earlier line of data, and
want to insert a row after each cell in column D that contains a 2, an
insert two rows after each cell in column D that contains a 3.

I'm having a tough time figuring out how to go about this. The onl
stab I've made at it is the following, which doesn't even do anything


range("D:D").Select
If Value = 2 Then
Selection.EntireRow.Insert (xlShiftDown)
ElseIf Value = 3 Then
Selection.EntireRow.Insert (xlShiftDown)
Selection.EntireRow.Insert (xlShiftDown)
End If

I would greatly appreciate any assistance with this. thank you

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Row insertion problem

Of course it doesn't do anything. There are several problems:
1) you are trying to select a column, not a row (and not doing i
correctly in any case)
2) you need .Value instead of Value

You want something like this:

select the cell you want to check, then
thisRow = ActiveCell.Row
if cells(thisRow, "D").Value = 2 then
Cells(thisRow, "D").entireRow.Insert (xlShiftDown)

et ceter

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Row insertion problem

Well that worked great (once I realized that having a non-numeric valu
in the last cell was what was giving me an error), thank you Norma
jones

--
Message posted 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
automatic insertion of row renegade Excel Worksheet Functions 3 January 27th 10 10:58 AM
Row Insertion mlockman Excel Discussion (Misc queries) 0 April 17th 09 03:33 PM
Row Insertion Problem robot[_3_] New Users to Excel 2 February 7th 09 04:38 AM
Rows Insertion b166er Excel Worksheet Functions 1 June 22nd 06 04:41 PM
Row insertion macro Jeff Excel Programming 2 November 13th 03 04:35 PM


All times are GMT +1. The time now is 09:47 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"