Delet columns and rows

shrikant sinnur

New Member
Joined
Jan 29, 2009
Messages
16
dear sir,

i most of the time use excel.

i want to know that,

i want to keep columns from A to H and Rows from 1 to 55.

i want to delete rest all columns and rows and it should not generate the columns and rows again and again.

pl, help me

thanking you

shrikant
 
Last edited:
HI, shrikant,

You can not "delete" those rows adn columns.
You can hide them though. (select, rightclick and see in the menu you get)

kind regards,
Erik
 
Upvote 0
Try

Code:
Sub DelColRw()
Dim LR As Long, LC As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
LC = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
If LC > 8 Then Range(Cells(1, 9), Cells(1, LC)).EntireColumn.Delete
If LR > 55 Then Rows("56:" & LR).Delete
End Sub
 
Upvote 0
Perhaps you mean this

Code:
Sub DelColRw()
Range(Cells(1, 9), Cells(1, Columns.Count)).EntireColumn.Hidden = True
Rows("56:" & Rows.Count).Hidden = True
End Sub
 
Upvote 0
VoG
hai,

i pasted your code in vb editor like this but not worked.

Private Sub Worksheet_Activate()
Dim LR As Long, LC As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
LC = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
If LC > 8 Then Range(Cells(1, 9), Cells(1, LC)).EntireColumn.Delete
If LR > 55 Then Rows("56:" & LR).Delete
End Sub

tell how to use the code.
 
Upvote 0
To use the code in that way you have to place it in the sheet's code module. Right click the sheet tab, select View Code and paste in the code.
 
Upvote 0
you are welcome!

A worksheet has a fixed amount of columns and rows which are available for use: you can NOT change that.
You can select them and hide them.
Alternatively you can restrict the scrollarea: so even when those columns and rows stay visible the user can not "see" them on screen.
 
Upvote 0
I wasn't sure if you wanted to hide or clear the rest of the columns and rows so I did a macros for both:
Code:
Sub HideColumnsAndRows()

'Hides the columns I->
Range(Columns(9), Columns(Columns.Count)).EntireColumn.Hidden = True
'Hides the rows 56->
Range(Rows(56), Rows(Rows.Count)).EntireRow.Hidden = True

End Sub

Sub ClearColumnsAndRows()

'Clears the columns I->
Range(Columns(9), Columns(Columns.Count)).Clear
'Clears the rows 56->
Range(Rows(56), Rows(Rows.Count)).Clear

End Sub
Both macros work on activesheet.
 
Upvote 0

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