Transfer of data range (multiple cells) from one sheet to another sheet automatically at the next blank row.

SomethingNew

New Member
Joined
Jul 2, 2024
Messages
2
Office Version
  1. 2016
  2. Prefer Not To Say
Platform
  1. Windows
  2. Web
First time posting sorry if I am not posting properly.

I have used the code below previously to automatically input data from one cell to a master data sheet but now I need it to input multiple cells down the column.

VBA Code:
Sub data_input()

ws_output = "SAMPLE FINAL"

next_row = Sheets(ws_output).Range("B" & Rows.Count).End(xlUp).Offset(1).Row

Sheets(ws_output).Cells(next_row, 1).Value = Range("DESCRIPTION").Value
Sheets(ws_output).Cells(next_row, 18).Value = Range("QTY").Value
Sheets(ws_output).Cells(next_row, 19).Value = Range("UOM").Value

End Sub

To make it submit multiple cells information I tried changing the column range's name instead of just the one singular cell.
ex.
Range A2:A12 changed name to DESCRIPTION


It only accepts the first row of the range and nothing else is listed below, I am unsure if my approach is completely wrong since I assumed the range of cells is included in the Range("DESCRIPTION").Value.

If there's another way to do this or if I'm just making a mistake in my approach I would appreciate any help
 
Last edited by a moderator:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
When you use an assignment ie .value = .value the range sizes on both sides of the "=" need to be the same size.
Assuming your 3 range names are all the same size, try something like this:

VBA Code:
Sub data_input()

Dim ws_output As String
Dim next_row As Long
Dim NoOfRows As Long

ws_output = "SAMPLE FINAL"

next_row = Sheets(ws_output).Range("B" & Rows.Count).End(xlUp).Offset(1).Row

NoOfRows = Range("Description").Count

With Sheets(ws_output)
    .Cells(next_row, 1).Resize(NoOfRows).Value = Range("DESCRIPTION").Value
    .Cells(next_row, 18).Resize(NoOfRows).Value = Range("QTY").Value
    .Cells(next_row, 19).Resize(NoOfRows).Value = Range("UOM").Value
End With

End Sub
 
Upvote 1
Solution
Thank you so much for this, it's made the column off by 1 but I just changed the

.Cells(next_row, 1).Resize(NoOfRows).Value = Range("DESCRIPTION").Value

into

.Cells(next_row, 2).Resize(NoOfRows).Value = Range("DESCRIPTION").Value

just for reference in case anyone tries it.

Thank you again.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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