Fill up non contiguous cells from contiguous cells/clipboard/range

Bawltea

New Member
Joined
Aug 17, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
My destination sheet contains Seat No. against which Roll No. (stored sequentially in another excel file) is to be filled up. Sample destination look like this:
1723906665674.png

The source file has Roll No in a sequential column and I have to copy/paste the Roll Nos. one column at a time for many rooms, for three to four session a day and sometimes for more than twenty day. Filling up the destination fill in just a single paste from Clipboard would really help and would be more helpful if automated.
 

Attachments

  • 1723906478741.png
    1723906478741.png
    15.6 KB · Views: 4

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
What does the data in the source file look like?
 
Upvote 0
A series of Roll No. in a column with corresponding names which is not needed for the destination file
Sl. No.Roll No.Name
1ECO24-010James Smith
2ECO24-019Nina Gomez
3EDN24-021Luna Lee
4GEO24-032Gina Lorenz
5HIS24-044Danny Kane
6POL24-107Harold Reed
7POL24-108Abel Humber
8PSY24-112John Ford
9PUB24-115Dana Lang
Like this
 
Upvote 0
Are there 32 seat numbers with 32 corresponding Roll No.'s in the source file? Also, is the data in the source file in columns A, B and C? Does the data in the destination file start in column A?
 
Upvote 0
Assuming that the data in the source file is in columns A, B and C and that the source file is already open, place this macro in a regular module in the destination workbook and run it from there. Change the sheet names (in red) and the workbook name (in blue) to suit your needs.
Rich (BB code):
Sub FillRollNUm()
    Application.ScreenUpdating = False
    Dim v As Variant, i As Long, fnd As Range, desWS As Worksheet, srcWS As Worksheet
    Set desWS = ThisWorkbook.Sheets("Sheet1")
    Set srcWS = Workbooks("Source.xlsx").Sheets("Sheet1")
    v = srcWS.Range("A2", srcWS.Range("A" & Rows.Count).End(xlUp)).Resize(, 2).Value
    For i = LBound(v) To UBound(v)
        Set fnd = desWS.UsedRange.Cells.Find(v(i, 1), LookIn:=xlValues, lookat:=xlWhole)
        If Not fnd Is Nothing Then
            fnd.Offset(, 1) = v(i, 2)
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Are there 32 seat numbers with 32 corresponding Roll No.'s in the source file? Also, is the data in the source file in columns A, B and C? Does the data in the destination file start in column A?
The number of seats vary and also the setting i.e., number of rows and columns
 
Upvote 0
Assuming that the data in the source file is in columns A, B and C and that the source file is already open, place this macro in a regular module in the destination workbook and run it from there. Change the sheet names (in red) and the workbook name (in blue) to suit your needs.
Rich (BB code):
Sub FillRollNUm()
    Application.ScreenUpdating = False
    Dim v As Variant, i As Long, fnd As Range, desWS As Worksheet, srcWS As Worksheet
    Set desWS = ThisWorkbook.Sheets("Sheet1")
    Set srcWS = Workbooks("Source.xlsx").Sheets("Sheet1")
    v = srcWS.Range("A2", srcWS.Range("A" & Rows.Count).End(xlUp)).Resize(, 2).Value
    For i = LBound(v) To UBound(v)
        Set fnd = desWS.UsedRange.Cells.Find(v(i, 1), LookIn:=xlValues, lookat:=xlWhole)
        If Not fnd Is Nothing Then
            fnd.Offset(, 1) = v(i, 2)
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
Thank you very much for your help. Now let me try. Will update ASAP. But it's getting late here, might not finish it tonight.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
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