Merge to Columns with Unknown length

  • Thread starter Thread starter Steve M
  • Start date Start date
S

Steve M

Hi - I have a spreadsheet with 2 columns

House Name
House Number

I want to merge these to columns and I have used the following

=B2&" "&C2&" "

This works fine except I want to run a macro that automatically merge
these 2 columns from a helper column I created - the only problem bein
I do not know how many House names or numbers need merging pe
spreadsheet so my macro automatical self calculates 500 rows but th
database these spreadsheets can uploaded in to keeps reading the blan
spaces left behind in the empty rows and failing

Anyone know how to let the macro know when to stop at the last row o
data please

Any help appreciate
 
Puts the merged cells B and C into cell A for only rows up to the last
column B entry.....

with activesheet
xlastrow = .cells(rows.count,2).end(xlup).row
for x = 1 to xlastrow
.cells(x,1) = .cells(x,2) & " " & .cells(x,3) & " "
next x
end with
 
HI Nigel,

I have the same situation but I need to put the data that is in column
J and move it to column F in the same row. How would I alter this code to
accomplish this. The cells in Column F are empty on these rows where there
is data in column J. Thanks
Nigel said:
Puts the merged cells B and C into cell A for only rows up to the last
column B entry.....

with activesheet
xlastrow = .cells(rows.count,2).end(xlup).row
for x = 1 to xlastrow
.cells(x,1) = .cells(x,2) & " " & .cells(x,3) & " "
next x
end with
 
In Column J, assuming the values are constants and not formulas and the
other cells are empty:

set rng = Columns(10).SpecialCells(xlConstants)
for each cell in rng
cells(cell.row,"F").Value = cell.Value
Next
rng.ClearContents
 
Wow, this works great Tom and I understand the code which is good since I'm
just a beginner at this. Let me take this one step further.

Same scenario with a report that varies in length each day. When I'm
downloading this report, some data is incorrectly placed into Column I, that
should be in Column J on the same row. The cells in those rows in column J
are empty. Some of the information in column I is correct however so I only
want to move the data in each cell in column I that have greater than 7
characters. Is that even doable based on that criteria of greater than 7
characters?
 

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

Back
Top