Roman F
asked on
How to delete the data in excel sheets
I have an excel book with thre sheets (tabs). The first one is summary, two others are contain data. Let say sheet A,sheet B,sheet C,
Sheet B and Sheet C looks like
Name Count
Steve 100
Piter 50
Ann 25
I would like to run macro which will delete Sheet B and sheet C data but leave the header and format of the columns
The header is Name and Count, the format is string and number accordingly
Sheet B and Sheet C looks like
Name Count
Steve 100
Piter 50
Ann 25
I would like to run macro which will delete Sheet B and sheet C data but leave the header and format of the columns
The header is Name and Count, the format is string and number accordingly
Try this sub
Sub deldata()
Application.Intersect(Shee ts("B").Us edRange.Of fset(1, 0), Sheets("B").Columns("A:B") ).ClearCon tents
Application.Intersect(Shee ts("C").Us edRange.Of fset(1, 0), Sheets("C").Columns("A:B") ).ClearCon tents
End Sub
Sub deldata()
Application.Intersect(Shee
Application.Intersect(Shee
End Sub
ASKER
thank you but i got the message
Run time error '9'
Subscript out of range
Run time error '9'
Subscript out of range
ASKER
sorry, my bad
it is working
only one thing: the table border still remains, how to clear the border?
it is working
only one thing: the table border still remains, how to clear the border?
Are you using it on the same file or is it a different file?
You had mentioned
"delete Sheet B and sheet C data but leave the header and format of the columns"
But if you like to clear that also then change clearcontents to clear
Saqib
"delete Sheet B and sheet C data but leave the header and format of the columns"
But if you like to clear that also then change clearcontents to clear
Saqib
ASKER
You are right, if i will clear insead of ClearContent it will delete *
But i want to leave the format of the data, like number and text
so i need to remove the border of the table...
Sheets("B").Selection.Bord ers.LineSt yle = xlNone---somethhing like that???
But i want to leave the format of the data, like number and text
so i need to remove the border of the table...
Sheets("B").Selection.Bord
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you, the second and fourth line is the same as Clear, it removes the formating of the column
which is not good,
ok, i am really appreciate your help. I will ask Experts about another problem how to make the Coumn B Number
which is not good,
ok, i am really appreciate your help. I will ask Experts about another problem how to make the Coumn B Number
No, it does not remove any other formatting. You should try it again.
ASKER
well, the format of the column B was a number, with 0 decimal places and use a comma as a 1000 separator. Now it is gone and when i enter the number for example 2500 insead of 2,500 it stays as 2500
When I run the macro the number formats are not disturbed.
I suggest that you exit excel, download the file which you have uploaded on this page and then try it again.
Saqib
I suggest that you exit excel, download the file which you have uploaded on this page and then try it again.
Saqib
ASKER
Table.xls