Trying to take input for rows from user

siddo

Board Regular
Joined
May 26, 2020
Messages
106
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
VBA Code:
Private Sub CommandButton1_Click()

a = InputBox("Enter the Row", "Excel VBA Says", "Please enter data")
    Rows("a").Select
    Selection.Copy
    Selection.Insert Shift:=xlDown
    Range("L8").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Rows("a" + 1).Select
    Selection.Rows.Group
    ActiveSheet.Outline.ShowLevels RowLevels:=1
    
End Sub
Im getting an error at Rows("a") .Select section can someone help
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You need to remove the quotes from around the a, so it's just Rows(a)
 
Upvote 0
Try something like:
VBA Code:
Dim a As Integer

a = Application.InputBox("Enter the Row", "Excel VBA Says", "Please enter data", Type:=1)
    Rows(a).Select
    Selection.Copy
    Selection.Insert Shift:=xlDown
    Range("L8").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    Rows(a + 1).Select
    Selection.Rows.Group
    ActiveSheet.Outline.ShowLevels RowLevels:=1
 
Upvote 0
You need to remove the quotes from around the a, so it's just Rows(a)
A quick question instead of rows can I identify the rows using the S.No column I have written C1,C2 like this in my serial number column so instead of putting a row can I include C1 and C2
 
Upvote 0

Forum statistics

Threads
1,224,809
Messages
6,181,075
Members
453,020
Latest member
mattg2448

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top