Copy cell to first BLANK cell in column, NOT the first blank cell from the last row used

Eyeson15

Board Regular
Joined
Apr 30, 2015
Messages
201
Hi,

Please help me create a VBA code.

I have been googling for a long time and the solutions it provides is not quiet what I need.

I would like to copy a cell and paste into FIRST BLANK CELL in column B.

Column B is a long column of data and it has gaps. So the cell I select needs to be copied into the first BLANK gap in column B.

All the solutions seem to paste it at the bottom of column B after the last non-blank cell.

Thank you!

James
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I sort of found this which works so anyone else looking for solution to similar problem, try it.

I wonder if there is a simpler solution.

Code:
Sub kansdasdasdasdasds()

    Dim r1 As Range
    Dim r2 As Range
    Dim r3 As Range
    Set r1 = Sheets(1).Range("A1")
    Set r2 = Sheets(2).Range("B1:B100")
    For Each r3 In r1
    If r3.Value = "" Then
        r2.Copy
        r3.PasteSpecial xlPasteValuesAndNumberFormats
        Exit Sub
    End If
    Next
    
End Sub
 
Last edited:
Upvote 0
You can copy your unspecified cell to this cell...

Columns("B").SpecialCells(xlBlanks)(1)

For example, if the cell with the data you want to copy is cell A1, then you would write this...

Range("A1").Copy Columns("B").SpecialCells(xlBlanks)(1)
 
Last edited:
Upvote 0
Try this:
Copies value in Range("G1") to first empty cell in column "B"

Code:
Sub Copy_Me_To_Column_B_First_Empty()
Dim ans As Long
ans = Columns(2).End(xlDown).Row + 1
Range("G1").Copy Destination:=Range("B" & ans)
End Sub
 
Upvote 0
Hi Rick

Thank you for your input.

It still skips over 'some' of the blanks. I also tried .SpecialCells(xlCellTypeBlanks)(1) and it skips over some of the blank cells. Not sure if this information helps but these blank cells does not have any formula but does have conditional formatting.

James
 
Upvote 0
It still skips over 'some' of the blanks. I also tried .SpecialCells(xlCellTypeBlanks)(1) and it skips over some of the blank cells.
Then those cells are not blank (they may have invisible characters such as spaces in them or, alternately, they may have formulas in them which displays the empty text string "").
 
Upvote 0
Hi My Aswer.

Thanks again for your input.

Same problem as Rick's code. It skips over some of the blank cells. These blanks do not have any formula but does have conditional formatting.

Also.. is it possible to .PasteSpecial xlPasteValuesAndNumberFormats because there are formulas in the cell I'm copying from.

James
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,727
Members
449,049
Latest member
MiguekHeka

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