VBA CODE -- Find and insert

MichaelJ300

Board Regular
Joined
Oct 30, 2013
Messages
143
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I’m not sure how to explain what I need here…
I need to identify the first blank space then copy and paste information in that area. Then find the second space and copy and paste information in this area.

Step 1: identify the first empty row and copy and paste from a different tab named “Control” cell A21.
Step 2: Identify the second empty row copy and paste from a different tab named “Control” cell A22.

Thanks in advance…
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hello,

I’m not sure how to explain what I need here…
I need to identify the first blank space then copy and paste information in that area. Then find the second space and copy and paste information in this area.

Step 1: identify the first empty row and copy and paste from a different tab named “Control” cell A21.
Step 2: Identify the second empty row copy and paste from a different tab named “Control” cell A22.

Thanks in advance…

Hi Michael,
Try this code it, it looks in column A for the first empty cell and copies cell A21 into it, then looks for the second empty cell and copies Cell A22 into it.

Code:
Sub EmptyRow()    
    With Worksheets(1)
        .Activate
        .Cells(1, 1).End(xlDown).Offset(1, 0) = Worksheets("Control").Cells(21, 1)
        .Cells(1, 1).End(xlDown).Offset(1, 0) = Worksheets("Control").Cells(22, 1)
    End With
        


End Sub
 
Upvote 0
This works!!! Is there a way that I can take the format from the Worksheets("Control").Cells(21, 1)?
 
Upvote 0
I suppose the easiest in my mind would be to copy and paste.

Code:
Sub EmptyRow()    Worksheets("Control").Cells(21, 1).Copy
    Worksheets(1).Cells(1, 1).End(xlDown).Offset(1, 0).PasteSpecial
    
    Worksheets("Control").Cells(22, 1).Copy
    Worksheets(1).Cells(1, 1).End(xlDown).Offset(1, 0).PasteSpecial
    
    Worksheets(1).Activate
End Sub
 
Upvote 0
nope didn't work :(

I tried this still nothing just a little modification.

Sheets("TA TOTALS").Select
Worksheets("Control").Cells(21, 1).Copy
Worksheets(1).Cells(1, 1).End(xlDown).Offset(1, 0).PasteSpecial
Worksheets("Control").Cells(22, 1).Copy
Worksheets(1).Cells(1, 1).End(xlDown).Offset(1, 0).PasteSpecial
 
Upvote 0
Did it not work in terms of copying the format, or did it not even copy the values? When I run it, it copies text to the sheet and keeps the color of the text. What formatting are you trying to keep?
 
Upvote 0
It wouldn't copy anything. I'm trying to copy a merge cell from Worksheets("Control").Cells(21, 1).Copy. It does have color and boldness. The first code worked great other than the formatting. Not sure what I'm doing wrong here. I tried a couple different varaition but the same result.
 
Upvote 0
Insted of taking 1 cell is there code to take the entire row from Worksheets("Control"). 21?
 
Upvote 0
Yes, Worksheets("Control").Rows(21).Copy. The issue with copying a merge cell is you need to paste it into an equal size range of cells I believe. Copying the row should work though.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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