VBA help, merge City, State

brent3162

New Member
Joined
Jul 13, 2024
Messages
11
Office Version
  1. 365
Platform
  1. MacOS
Simple for some, not for me. I have a form where I have a list tied to a named range worksheet called customer (see attached). When I select a customer it populates the form with the address of that customer just below the customer name. Then, below the address add the same customers phone number prefaced with "PH:" [PhoneNumber]. I'm struggling with bringing all the address cells together into one field using VBA as well as placing the phone number on the next row below address. I know how to merge the cell for all the address fields using the concatenate function within excel but can't figure out how to do this with VBA.

Also I'm using excel on MacOS and am trying to add this code to run in the background so that when I change the customer name it automatically updates these two rows with the correct address/phone#
 

Attachments

  • invoice.gif
    invoice.gif
    74.7 KB · Views: 22
  • customer.gif
    customer.gif
    62.7 KB · Views: 27
  • address.gif
    address.gif
    22.5 KB · Views: 18
Replace the "Get_Data" macro with following.
Code:
Sub Get_Data()
    Range("C8").Value = Join(Application.Transpose(Application.Transpose(Sheets("CUSTOMER").Columns(1).Find(Range("C7").Value, , , 1).Offset(, 3).Resize(, 4))), ", ")
    Range("C9").Value = "Ph: " & Sheets("CUSTOMER").Columns(1).Find(Range("C7").Value, , , 1).Offset(, 1).Value
End Sub
@jolivanes yes, this fixed the issue. Thanks so much. Now I have two solutions to my problem. You guys ROCK!!!
 

Attachments

  • fixed issues.gif
    fixed issues.gif
    196.1 KB · Views: 2
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top