PDA

View Full Version : Solved: Combining two cells in VBA



lanhao
05-17-2006, 01:29 PM
Hi there, I've been working on an way of trying to get two separate values of data to combine into one value so it would be able to be outputted to a user form for some of my co-workers.

One of the values is Text, the other is a number. What I am basically looking to do is figure out a way of having the VB side of things, automatically combine the two values, so if cell H2 read 'A' and I2 read '21' it would automatically fill out the other information in another column and give the value 'A21'.

I'm not sure what kind of command or function would apply to this case specifically, and i was trying to look through some help files (and that did more damage than good). Any suggestions, tips/help would be greatly appreciated. :)

TonyJollans
05-17-2006, 05:15 PM
In cell J2, put =H2&I2

debauch
05-17-2006, 06:52 PM
I'm with Tony. Just have a cell in excel that already joins the information, and have vb pull that (in his example J2).

An alternative option, is :

TextBox1.Value = Sheets("sheet1").Range("A1") & ("a2")

.... i think first is far easier.

lanhao
05-17-2006, 09:44 PM
actually, doing it that way slowed down the process entirely, Tony's suggestion that is. The problem is that this workbook is going to be getting up in size and could potentially go through about 2000 rows of data. It drastically slowed things down, however, the other way suggested using the ranges worked out phenomenally well.

Thank you both for your suggestions on this, I truly do appreciate the help. :)

TonyJollans
05-18-2006, 12:00 AM
I'm not sure I follow what you are doing but there is no way a trivial formula like that should have a significant performance hit on 2000 rows.

lanhao
05-18-2006, 05:08 AM
well, i think that it was doing teh slowdown was that teh data got entered into one worksheet, adn the total was output on another sheet, if i neglected to mention that I'm sorry. ^^;