VBA with Excel

Discussion in 'Software' started by bakwoi, Jun 2, 2004.

  1. bakwoi

    bakwoi Private E-2

    I have an Excel worksheet with "Account: 7" in cell A2, and "65432 acc" in cell A3. Is it possilbe just using a VBA macro to combine the "7" and the "65432" and put that in cell A1, while leaving the cells A2 and A3 as they are? If so what is the code for it.

    Thank you
     
  2. Kodo

    Kodo SNATCHSQUATCH

    put this as the formula for CELL A1
    =RIGHT(A2,1)&LEFT(A3,5)

    this is VERY general and specific the length of sample data you posted. If the data's length varies, then there will be an issue with the forumla and a more dynamic function will be needed.
     
  3. kkj

    kkj Private E-2

    I just tested the following on my home computer and it worked for your situation as you have described it. Try this:


    Sub Macro1()


    Cells(1, 1).Select
    ActiveCell.FormulaR1C1 = Right(Trim(Cells(2, 1)), 1) & Trim(Cells(3, 1))


    End Sub


    Best of luck to you!
    Kelly
    <A HREF="http://kellyjones.netfirms.com">http://kellyjones.netfirms.com</A>
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds