Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
hol hol is offline
external usenet poster
 
Posts: 12
Default Deleting row using vb code?

I have the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then Rows(3).Delete
End Sub

Using this code how can I then insert a row at the bottom of the spreadsheet?
--
hol
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Deleting row using vb code?

Hi

Try amending the code to

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then
Rows(3).Delete
Target.EntireRow.Insert
End If
End Sub

I'm not exactly certain where you want your row inserted, so you might have
to amend the line
Target.EntireRow.Insert
to
Target.Offset(-1,0).EntireRow.Insert
to get your insertion in the correct place

--

Regards
Roger Govier

"hol" wrote in message
...
I have the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then Rows(3).Delete
End Sub

Using this code how can I then insert a row at the bottom of the
spreadsheet?
--
hol


  #3   Report Post  
Posted to microsoft.public.excel.misc
hol hol is offline
external usenet poster
 
Posts: 12
Default Deleting row using vb code?

Thanks Roger,
I need to insert the new row right at the bottom of the spreadsheet ie
65,000+ what ever the total number of rows in a spreadsheet.
--
hol


"Roger Govier" wrote:

Hi

Try amending the code to

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then
Rows(3).Delete
Target.EntireRow.Insert
End If
End Sub

I'm not exactly certain where you want your row inserted, so you might have
to amend the line
Target.EntireRow.Insert
to
Target.Offset(-1,0).EntireRow.Insert
to get your insertion in the correct place

--

Regards
Roger Govier

"hol" wrote in message
...
I have the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then Rows(3).Delete
End Sub

Using this code how can I then insert a row at the bottom of the
spreadsheet?
--
hol



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Deleting row using vb code?

Hi

I don't understand.
Why would you want to be inserting a row at 65536?
Row 65536 will always be there.
If you delete rows in a spreadsheet, it is the contents of the row that
disappear, and the rows move up. Excel retains the full number of rows in
the sheet at all times.

Perhaps you can explain a little more what you are trying to do.
I had thought, that perhaps you had some totals in row 101, and when you got
to row 100, you wanted to delete row 3, but have a new row available for
data entry above your total.
--

Regards
Roger Govier

"hol" wrote in message
...
Thanks Roger,
I need to insert the new row right at the bottom of the spreadsheet ie
65,000+ what ever the total number of rows in a spreadsheet.
--
hol


"Roger Govier" wrote:

Hi

Try amending the code to

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then
Rows(3).Delete
Target.EntireRow.Insert
End If
End Sub

I'm not exactly certain where you want your row inserted, so you might
have
to amend the line
Target.EntireRow.Insert
to
Target.Offset(-1,0).EntireRow.Insert
to get your insertion in the correct place

--

Regards
Roger Govier

"hol" wrote in message
...
I have the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then Rows(3).Delete
End Sub

Using this code how can I then insert a row at the bottom of the
spreadsheet?
--
hol



  #5   Report Post  
Posted to microsoft.public.excel.misc
hol hol is offline
external usenet poster
 
Posts: 12
Default Deleting row using vb code?

Ah! Thanks Roger,
You have answered the question in your reply. It makes sense now thank you
very much.
--
hol


"Roger Govier" wrote:

Hi

I don't understand.
Why would you want to be inserting a row at 65536?
Row 65536 will always be there.
If you delete rows in a spreadsheet, it is the contents of the row that
disappear, and the rows move up. Excel retains the full number of rows in
the sheet at all times.

Perhaps you can explain a little more what you are trying to do.
I had thought, that perhaps you had some totals in row 101, and when you got
to row 100, you wanted to delete row 3, but have a new row available for
data entry above your total.
--

Regards
Roger Govier

"hol" wrote in message
...
Thanks Roger,
I need to insert the new row right at the bottom of the spreadsheet ie
65,000+ what ever the total number of rows in a spreadsheet.
--
hol


"Roger Govier" wrote:

Hi

Try amending the code to

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then
Rows(3).Delete
Target.EntireRow.Insert
End If
End Sub

I'm not exactly certain where you want your row inserted, so you might
have
to amend the line
Target.EntireRow.Insert
to
Target.Offset(-1,0).EntireRow.Insert
to get your insertion in the correct place

--

Regards
Roger Govier

"hol" wrote in message
...
I have the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 100 Then Rows(3).Delete
End Sub

Using this code how can I then insert a row at the bottom of the
spreadsheet?
--
hol



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
VBA Code for Deleting a Row [email protected] Excel Worksheet Functions 3 September 6th 07 03:23 PM
deleting selected worksheets using vb code George Excel Discussion (Misc queries) 1 October 31st 06 05:14 PM
Deleting Workbook_Open code Paige Excel Discussion (Misc queries) 3 January 31st 06 07:39 PM
Deleting Code from VBA Noemi Excel Discussion (Misc queries) 1 January 24th 06 08:55 AM
Deleting ALL duplicates using Pearson's code [email protected] Excel Worksheet Functions 2 May 6th 05 01:50 PM


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