Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 123
Default inserting in wrong location

hi.
Can someone review the below code and suggest what i need to change to get
the macro to insert the range name " sample_style" where the cursor was at
the time the macro button was pressed. Currently, the macro inserts the
"sample style", beneath the "sample_style" range.
thanks in advance for any advice.
thx

If MsgBox("Do you want to insert a new style at your cursor", vbYesNo +
vbDefaultButton2) = vbYes Then

ActiveCell.EntireRow

Range("sample_style").Select
Selection.Copy
ActiveCell.EntireRow.Insert Shift:=xlDown
Else
Exit Sub
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default inserting in wrong location

Tami, try the below and feedback

If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
ActiveCell.EntireRow.Insert Shift:=xlDown
Rows(Range("sample_style").Row).Copy Rows(ActiveCell.Row)
End If

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

hi.
Can someone review the below code and suggest what i need to change to get
the macro to insert the range name " sample_style" where the cursor was at
the time the macro button was pressed. Currently, the macro inserts the
"sample style", beneath the "sample_style" range.
thanks in advance for any advice.
thx

If MsgBox("Do you want to insert a new style at your cursor", vbYesNo +
vbDefaultButton2) = vbYes Then

ActiveCell.EntireRow

Range("sample_style").Select
Selection.Copy
ActiveCell.EntireRow.Insert Shift:=xlDown
Else
Exit Sub
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 123
Default inserting in wrong location

yeah, finally some progress!!....it did insert one line...but "sample_style"
actually consists of 4 lines...the macro only copied/inserted the first
line...any suggestions, Jacob?

"Jacob Skaria" wrote:

Tami, try the below and feedback

If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
ActiveCell.EntireRow.Insert Shift:=xlDown
Rows(Range("sample_style").Row).Copy Rows(ActiveCell.Row)
End If

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

hi.
Can someone review the below code and suggest what i need to change to get
the macro to insert the range name " sample_style" where the cursor was at
the time the macro button was pressed. Currently, the macro inserts the
"sample style", beneath the "sample_style" range.
thanks in advance for any advice.
thx

If MsgBox("Do you want to insert a new style at your cursor", vbYesNo +
vbDefaultButton2) = vbYes Then

ActiveCell.EntireRow

Range("sample_style").Select
Selection.Copy
ActiveCell.EntireRow.Insert Shift:=xlDown
Else
Exit Sub
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default inserting in wrong location

Hi Tami

Try the below..

Application.ScreenUpdating = False
If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
Range("sample_style").Copy
ActiveCell.Insert Shift:=xlDown
Application.CutCopyMode = False
End If
Application.ScreenUpdating = True

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

yeah, finally some progress!!....it did insert one line...but "sample_style"
actually consists of 4 lines...the macro only copied/inserted the first
line...any suggestions, Jacob?

"Jacob Skaria" wrote:

Tami, try the below and feedback

If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
ActiveCell.EntireRow.Insert Shift:=xlDown
Rows(Range("sample_style").Row).Copy Rows(ActiveCell.Row)
End If

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

hi.
Can someone review the below code and suggest what i need to change to get
the macro to insert the range name " sample_style" where the cursor was at
the time the macro button was pressed. Currently, the macro inserts the
"sample style", beneath the "sample_style" range.
thanks in advance for any advice.
thx

If MsgBox("Do you want to insert a new style at your cursor", vbYesNo +
vbDefaultButton2) = vbYes Then

ActiveCell.EntireRow

Range("sample_style").Select
Selection.Copy
ActiveCell.EntireRow.Insert Shift:=xlDown
Else
Exit Sub
End If
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 123
Default inserting in wrong location

Nice!! Worked like a charm!

Do you mind briefly describing what the screen updating code does, just so i
can apply it later, if applicable?

"Jacob Skaria" wrote:

Hi Tami

Try the below..

Application.ScreenUpdating = False
If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
Range("sample_style").Copy
ActiveCell.Insert Shift:=xlDown
Application.CutCopyMode = False
End If
Application.ScreenUpdating = True

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

yeah, finally some progress!!....it did insert one line...but "sample_style"
actually consists of 4 lines...the macro only copied/inserted the first
line...any suggestions, Jacob?

"Jacob Skaria" wrote:

Tami, try the below and feedback

If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
ActiveCell.EntireRow.Insert Shift:=xlDown
Rows(Range("sample_style").Row).Copy Rows(ActiveCell.Row)
End If

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

hi.
Can someone review the below code and suggest what i need to change to get
the macro to insert the range name " sample_style" where the cursor was at
the time the macro button was pressed. Currently, the macro inserts the
"sample style", beneath the "sample_style" range.
thanks in advance for any advice.
thx

If MsgBox("Do you want to insert a new style at your cursor", vbYesNo +
vbDefaultButton2) = vbYes Then

ActiveCell.EntireRow

Range("sample_style").Select
Selection.Copy
ActiveCell.EntireRow.Insert Shift:=xlDown
Else
Exit Sub
End If
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default inserting in wrong location

Tami, turn screen updating off to speed up your macro code. You won't be able
to see what the macro is doing, but it will run faster. Turn it off and
try..to see the difference.

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

Nice!! Worked like a charm!

Do you mind briefly describing what the screen updating code does, just so i
can apply it later, if applicable?

"Jacob Skaria" wrote:

Hi Tami

Try the below..

Application.ScreenUpdating = False
If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
Range("sample_style").Copy
ActiveCell.Insert Shift:=xlDown
Application.CutCopyMode = False
End If
Application.ScreenUpdating = True

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

yeah, finally some progress!!....it did insert one line...but "sample_style"
actually consists of 4 lines...the macro only copied/inserted the first
line...any suggestions, Jacob?

"Jacob Skaria" wrote:

Tami, try the below and feedback

If MsgBox("Do you want to insert a new style at your cursor", _
vbYesNo + vbDefaultButton2) = vbYes Then
ActiveCell.EntireRow.Insert Shift:=xlDown
Rows(Range("sample_style").Row).Copy Rows(ActiveCell.Row)
End If

If this post helps click Yes
---------------
Jacob Skaria


"Tami" wrote:

hi.
Can someone review the below code and suggest what i need to change to get
the macro to insert the range name " sample_style" where the cursor was at
the time the macro button was pressed. Currently, the macro inserts the
"sample style", beneath the "sample_style" range.
thanks in advance for any advice.
thx

If MsgBox("Do you want to insert a new style at your cursor", vbYesNo +
vbDefaultButton2) = vbYes Then

ActiveCell.EntireRow

Range("sample_style").Select
Selection.Copy
ActiveCell.EntireRow.Insert Shift:=xlDown
Else
Exit Sub
End If
End Sub

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
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
question on links where info is added and cell location is wrong question on links where info is added an Links and Linking in Excel 1 October 5th 07 08:23 AM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
Wrong Hyperlink location after sorting Lawulm Excel Discussion (Misc queries) 6 November 17th 06 05:30 PM
Inserting after specific location on right click menu [email protected] Excel Discussion (Misc queries) 1 July 26th 06 11:29 PM


All times are GMT +1. The time now is 10:36 PM.

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"