Select next empty cell in different sheet

mach5j

New Member
Joined
Mar 31, 2014
Messages
9
I am new to VBA and have been trying to figure out how to get a current sheet to copy and paste to a different sheet in the next empty cell. Here is what I have so far. It works nicely except that it copies over the existing data.

Sub ChooseBlankCells()
Dim MyName As String
MyName = Worksheets("Main").Range("E4").Value
If Worksheets("Main").Range("E4").Value = 1 Then
Range("E6").Copy Worksheets("Week1").Range("B5")
Range("E8").Copy Worksheets("Week1").Range("C5")
Range("I6").Copy Worksheets("Week1").Range("D5")
Range("M6").Copy Worksheets("Week1").Range("E5")
End If

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try:

Code:
Sub ChooseBlankCells()

Dim MyName As String
Dim LastRow as Long

Lastrow = Sheets("Week1").Range("B10000").End(xlup).Row +1

MyName = Worksheets("Main").Range("E4").Value

     If Worksheets("Main").Range("E4").Value = 1 Then
          Range("E6").Copy Worksheets("Week1").Range("B" & Lastrow)
          Range("E8").Copy Worksheets("Week1").Range("C" & Lastrow)
          Range("I6").Copy Worksheets("Week1").Range("D" & Lastrow)
          Range("M6").Copy Worksheets("Week1").Range("E" & Lastrow)
     End If

End Sub
 
Upvote 0
Ok, now I would like to add a text box to the same code above. I have played around with it but have not been successful. I'm not sure if this can be done but in place of Range("E4") I would like to have a text box that will perform the same functions and paste to the next available empty cell in Worksheets("Week1"). Any help would be greatly appreciated.


Sub ChooseBlankCells()Dim MyName As StringDim LastRow as LongLastrow = Sheets("Week1").Range("B10000").End(xlup).Row +1MyName = Worksheets("Main").Range("E4").Value If Worksheets("Main").Range("E4").Value = 1 Then Range("E6").Copy Worksheets("Week1").Range("B" & Lastrow) Range("E8").Copy Worksheets("Week1").Range("C" & Lastrow) Range("I6").Copy Worksheets("Week1").Range("D" & Lastrow) Range("M6").Copy Worksheets("Week1").Range("E" & Lastrow) End IfEnd Sub</pre>
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,257
Members
448,880
Latest member
aveternik

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