importing text data into Excel sheet

abeed

Board Regular
Joined
Nov 19, 2005
Messages
79
Hi there: I have a workbook with 3 worksheets. I am impoting data into sheet1 and creating a report in sheet2.
Next I want to import data again in sheet1 and create another report in sheet3. But in the 2nd import, I still have the data that I imported 1st time for sheet2. How can I clean all data that I imported for sheet2? So that when I import data for sheet3, I will have fresh data in sheet1.

or do you have any better idea?
Thanks in advance
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
HI

Assuming that you know the range the data will be imported into then something like

range("a1:f50").clearcontents
or
columns("A:C").clearcontents

Tony
 

Fat Cat

Active Member
Joined
Nov 5, 2004
Messages
336
To add to Tony's post, to clear an entire sheet I have also used;

Sheets("Sheet1").UsedRange.ClearContents
 

abeed

Board Regular
Joined
Nov 19, 2005
Messages
79
Hi: Thanks a lot both of you. This been a great help.
I would be asking you again next few days. I am preparing a report.
Thanks again.
 

abeed

Board Regular
Joined
Nov 19, 2005
Messages
79

ADVERTISEMENT

Last used row in a column

Hi: how can I find out the last row in a certain column. Say I have a very long column with data and in my VB code I need to know what is the last row with data under this column. Assume all intermediate cells have data.(say Range(A1,Alastused etc).
I want to put the total of this colum at the cell which will be the next of the last used cell under that column.

Thanks in advance
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I do the same thing in one of my reports. I always have it in the total at the top. Whoever opens the report sees the info right away.

However, If you want it at the end I know someone will show you how to write code to get the desired last cell.

Michael :oops:
 

abeed

Board Regular
Joined
Nov 19, 2005
Messages
79

ADVERTISEMENT

Hi Michael:
Thanks. Even if you put the total at the top, how do you know the total number of rows to add up. Assuming you dont want to see the last cell or say this is happening while writing the VB code.

Abeed
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

To get the lastrow in a column then something like

lastrow = cells(rows.count,"A").end(xlup).row

This will get the last row in column A and put the number into the variable lastrow.


Tony
 

abeed

Board Regular
Joined
Nov 19, 2005
Messages
79
Hi tony:
lastrow = cells(rows.count,"A").end(xlup).row
Will this give me last row with data or last possible row in a sheet under certain column. I need last row with data in a column.

Thanks
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

Last row with data in a particular column (in this example, column A) on the currently active sheet.

Note that if you are trying to get this information on the non active sheet, then you will have to use the sheet name
lastrow = sheets("yourname").cells(rows.count,"A").end(xlup).row


Tony
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,498
Messages
5,832,060
Members
430,109
Latest member
tinezi

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
Top