VBA copy data from the cell next to first blank and paste

gwa

New Member
Joined
Oct 26, 2020
Messages
3
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Web
Hi there,

I have been trying to put togtherer a VBA that looks for the first blank cell in a column, then copies the value of the cell on the right (next to the blank cell), and pastes it on the first blank cell in another column on another tab.
I would be thankful if you suggest what the above code might be, or an excel/VBA workaround that can achieve the same outcome. Thank you.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
What are the names of the two sheets? In which column on the first sheet are you searching for the first blank cell? In which column in the second sheet are you pasting the value?
 
Upvote 0
What are the names of the two sheets? In which column on the first sheet are you searching for the first blank cell? In which column in the second sheet are you pasting the value?
"Deliveries" and "Info", looking for the first blank cell in Sheets("Info"), column "I", then offsetting to the cell on the right in column "J", coping the value from "J", then pasting in the first blank in column "I" on Sheets("Deliveries).
 
Upvote 0
Try:
VBA Code:
Sub CopyData()
    Application.ScreenUpdating = False
    Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet, x As Long
    x = Range("A2:A" & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
    Set srcWS = Sheets("Info")
    Set desWS = Sheets("Deliveries")
    x = srcWS.Range("I2:I" & srcWS.Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
    With desWS
        .Cells(.Rows.Count, "I").End(xlUp).Offset(1) = srcWS.Range("J" & x)
    End With
    Application.ScreenUpdating = True
End Sub
 
  • Like
Reactions: gwa
Upvote 0
Solution
Great, it worked...it has been days..really appreciate!
Just one question, sometimes new lines of code affect what is appearing on some of the drop downs (I have a form with drop downs referencing to another sheet). The above was not in the begining, think I might have done something, so instead of drop down looking for content from 3 cells, it looks at 2 etc.
 
Upvote 0
I'm not sure what you mean. It would be helpful if you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

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