find last row, copy until end

S

Stephen

Hi Folks,

I have data that is pasted into column "A" from a macro. The macro first
deletes all data from the sheet ("Totals"), then runs a db query on another
sheet ("Receives"), subtotals, then copies the subtotals back to the original
sheet ("Totals"). that rage will always be dynamic and contain a differing
number of rows, but will always contain the word 'Total' at the end of each
value in column "A".

I would like the macro, once the new values are copied, to find the last
row, and remove the last 6 characters from each value in column "A".

I'm stuck on the finding last row, then looping through non empty rows and
trimming the string...

customer 1 Total -should become-
customer 1
customer name 2 Total -should become-
customer name 2

....and so on. Each value in column "A" will be of a variable length, and
removing the word 'Total' and the preceding space will solve my problem.

TIA!
 
C

Charles Chickering

Stephen what about using the Replace method on column A and replacing "
Total" with ""?

Range("A:A").Replace What:=" Total", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
 
S

Stephen

THAT'S FANTASTIC!!!!!

Thank you very much!

Charles Chickering said:
Stephen what about using the Replace method on column A and replacing "
Total" with ""?

Range("A:A").Replace What:=" Total", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top