VBA Help - there's got to be a clever approach

RaviWildcat

Board Regular
Joined
Jun 18, 2010
Messages
124
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi Everyone - I'm pretty rusty with my VBA so I appreciate your help!

1. I've got a master table that looks like this. This will contain a list of all my users and dates they are active

TeamNameDate
Central PerkMonica Geller5/20/2024
Central PerkMonica Geller5/21/2024
Central PerkMonica Geller5/22/2024
Central PerkMonica Geller5/23/2024


I am creating a separate input table where I can add names and dates for people I'll be adding to my master table. So, if my input table looks like this

TeamNameDate
Central PerkRoss Geller5/20/2024
Central PerkRoss Geller5/21/2024
......
......

I'd like to run my vba macro (or series of macros) to add the last two rows of the input table to the master table and get this:

TeamNameDate
Central PerkMonica Geller5/20/2024
Central PerkMonica Geller5/21/2024
Central PerkMonica Geller5/22/2024
Central PerkMonica Geller5/23/2024
Central PerkRoss Geller5/20/2024
Central PerkRoss Geller5/21/2024

If I was to do this by hand, I'd simply manually select all the items on the input table that are not '..", and then navigate to the bottom of the master table and paste it in.

I tried recording the steps to select the team column on the input table, search for text containing "..", then moving the cursor up and selecting all the rows on top before pasting into the master table. I also tried saving the input table as a table, applying a filter to select the information I want and then pasting to the end of the master table.

Is there a clever way to append this data?

Thank you!

Ravi

t

Any suggestions?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try on a copy. Adapt the ranges as needed.
VBA Code:
Sub InsertDataToMaster()
    Dim wsMaster As Worksheet
    Dim wsInput As Worksheet
    Dim lastRowMaster As Long
    Dim lastRowInput As Long
    Dim nextRowMaster As Long
    Dim inputRange As Range
    Dim masterRange As Range

    Set wsMaster = ThisWorkbook.Sheets("Master")
    Set wsInput = ThisWorkbook.Sheets("Input")
    nextRowMaster = wsMaster.Cells(wsMaster.Rows.Count, "A").End(xlUp).Row + 1
   
    Set inputRange = wsInput.Range("A2").CurrentRegion
    Set inputRange = inputRange.Offset(1, 0).Resize(inputRange.Rows.Count - 1)

    Set masterRange = wsMaster.Cells(nextRowMaster, 1)
    masterRange.Resize(inputRange.Rows.Count, inputRange.Columns.Count).Value = inputRange.Value
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
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