Select choosen rows

gosuansa

New Member
Joined
Jul 24, 2015
Messages
7
Hello MrExcel,
I have data in Range("A1:C100000"). In column A I have number accounts and I would like to have macro which select all (not filter) this rows which fullfilled conditions.
Thanks a lot for your help.


Best regards
Robert
 
Not that I know of.

How many rows do you want inserted?
We only know what you tell us.
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try this:
Code:
Sub add_rows()
'Modified 6/11/18 2:00 PM EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Dim accnum As String
accnum = InputBox("Enter account number")
For i = Lastrow To 2 Step -1
    If Cells(i, 1).Value = accnum Then Rows(i).Resize(8).Insert
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thx a lot for your help it works very good.

I have line of code:

Range("1:5,15:19,25:29,35:39").select


is it possible to select array when we change variable, for example:

i=5

so

Range("i:i+4,i+10:i+14,i+20:i+24,i+30:i+34").select

?




Try this:
Code:
Sub add_rows()
'Modified 6/11/18 2:00 PM EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Dim accnum As String
accnum = InputBox("Enter account number")
For i = Lastrow To 2 Step -1
    If Cells(i, 1).Value = accnum Then Rows(i).Resize(8).Insert
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
I'm assuming I answered your question and now you have a second question. Not sure i understand your new question.
 
Upvote 0

Forum statistics

Threads
1,223,979
Messages
6,175,761
Members
452,668
Latest member
mrider123

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