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
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

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
 

Watch MrExcel Video

Forum statistics

Threads
1,119,002
Messages
5,575,482
Members
412,668
Latest member
Lukep22
Top