Switching to a sheet or pasting in a row whose name matches a specific cell

mackemforever

New Member
Joined
Jun 29, 2020
Messages
6
Office Version
  1. 2019
Platform
  1. Windows
I posted a similar thread to this yesterday so I do apologise, but having spent another few hours bashing my head against this problem and going over the suggestions I've still not managed to figure out a solution to this issue. So please explain to me like I'm 5!

So I have the incredibly clunky bit of code below achieving the task of creating a new sheet with the customers name on it, copying the new data, pasting it on the customer sheet, applying a bit of formatting, locating the next available row on the master sheet and pasting the info there then clearing the New Info sheet, and while it's a weird bodge of recorded macro code and suggestions from here it works.

VBA Code:
    Range("A1:B4").Select
    Selection.copy
    Sheets.Add After:=Sheets(Sheets.Count)
    ActiveSheet.Name = Range("'New Info'!$B$1").Value
    Range("A1").Select
    ActiveSheet.Paste
    Columns("A:A").EntireColumn.AutoFit
    Columns("B:B").EntireColumn.AutoFit
    Range("A1:A4").Select
    Selection.Font.Bold = True
    Sheets("New Info").Select
    Range("B1:B4").Select
    Selection.copy
    Sheets("Master").Select
    Range("A1").Select ' change A1 to the top cell of your destination
    If ActiveCell.Offset(1, 0).Value <> "" Then Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=True, Transpose:=True
    Sheets("New Info").Select
    Range("b1:b4").Select
    Selection.ClearContents

Now for the problem.

On the New Info sheet I have an area for entering a new service. This takes the form of a drop-down menu which pulls the list of customer names from the Master sheet and a few cells to fill in.

Once I've filled in the relevant cells and selected the customer from the list I want the macro to copy the cells, switch to the sheet whose name matches the selected customer, and paste it, but I cannot for the life of me figure out how to switch to the correct sheet.

How would I switch to a sheet whose name matches the name I have selected?

Thanks.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Completely forgot the second part of the question.

After pasting the information in the customers sheet I want it to also switch to the Master sheet, locate which row matches the selected customer, and paste it in there too.

How can that be done?

Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,602
Members
449,089
Latest member
Motoracer88

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