Macro to send data from "Input" sheet to "Data" sheet

mark2002

New Member
Joined
Jan 19, 2023
Messages
6
Office Version
  1. 2021
Platform
  1. Windows
Hi all,
Still quite new to macros and I am having difficulty creating one that sends data from one tab (titled "Input") to the "Data" tab.

Ideally, the macro would be able to take the data from the "Input" (first image), and send it to "Data" (second image) either replacing existing data (using Shape in column A as the reference) or adding the new shape and attributes.

Essentially, it would need to function as the example below. (the highlighted cells showing the new or updated data)

Input.png
Data.png

Input 2.png
Data 2.png


Currently, my macro is only able to take the top row from the "Input" sheet and send it to the "Data" sheet.
It is unable to send multiple rows, or replace any of the 'Shape' attributes.

Input Example.png
Data Example.png


Sub Input_Button()

Dim sourceSheet As Worksheet
Dim dataSheet As Worksheet
Dim nextRow As Long

Set sourceSheet = Sheets("Input")
Set dataSheet = Sheets("Data")

nextRow = dataSheet.Range("A" & dataSheet.Rows.Count).End(xlUp).Offset(1).Row

dataSheet.Cells(nextRow, 1).Value = sourceSheet.Range("B2").Value
dataSheet.Cells(nextRow, 2).Value = sourceSheet.Range("C2").Value
dataSheet.Cells(nextRow, 3).Value = sourceSheet.Range("D2").Value


sourceSheet.Range("B2:B200").Value = ""
sourceSheet.Range("C2:C200").Value = ""
sourceSheet.Range("D2:D200").Value = ""

End Sub


Please let me know if you can help.

Thanks you so much!
-Mark
 
Hi Mark,

change code to

Rich (BB code):
  Else
    Set rngNext = wsData.Cells(1, clngColSHAPE - 1).EntireColumn.Find(wsSrc.Cells(lngCounter, clngColSHAPE).Value)
    With rngNext
      .Offset(0, -2).Value = wsSrc.Cells(lngCounter, clngColMAIN).Value
      If Not IsEmpty(.Offset(0, -2).Value) Then .Offset(0, -2).Interior.ColorIndex = 6
      
      .Offset(0, -1).Value = wsSrc.Cells(lngCounter, clngColSUB).Value
      If Not IsEmpty(.Offset(0, -1).Value) Then .Offset(0, -1).Interior.ColorIndex = 6
      
      .Offset(0, 1).Value = wsSrc.Cells(lngCounter, clngColCOLOR).Value
      If Not IsEmpty(.Offset(0, 1).Value) Then .Offset(0, 1).Interior.ColorIndex = 6

Holger
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,223,997
Messages
6,175,874
Members
452,679
Latest member
darryl47nopra

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