ComboBox value to next empty cell in table.

MarkOW

New Member
Joined
Jun 26, 2018
Messages
35
Hi, I am using the following code to export data from a ComboBox to the next empty cell in a range.
VBA Code:
Private Sub CommandButton6_Click()
 Dim LastRow As Long
        With ThisWorkbook.Sheets("Data")
            LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
            With .Range("B" & LastRow)
                .Value2 = ComboBox3.Value
                MsgBox "Entry Exported To List", vbInformation
            End With
        End With
End Sub
I have changed my data from a range to a table, the ComboBox selection is now pasting the next next empty row in the table instead of next empty cell in row.
Help if you can please.
Many thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi MarkOW,

maybe

VBA Code:
Private Sub CommandButton6_Click()
Dim LastRow As Long
With ThisWorkbook.Sheets("Data")
  LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
  With .Range("B" & LastRow + 1)
    .Value2 = ComboBox3.Value
    MsgBox "Entry Exported To List", vbInformation
  End With
End With
End Sub

Ciao,
Holger
 
Upvote 0
Hi MarkOW,

maybe

VBA Code:
Private Sub CommandButton6_Click()
Dim LastRow As Long
With ThisWorkbook.Sheets("Data")
  LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
  With .Range("B" & LastRow + 1)
    .Value2 = ComboBox3.Value
    MsgBox "Entry Exported To List", vbInformation
  End With
End With
End Sub

Ciao,
Holger
Thanks, that was my original code but it gave the following error.
1671902611830.png

Thanks
Mark
 
Upvote 0
Hi MarokOW,

why dio you use Value2 (I would have expected either Value or Text), what is the content you want to copy? Any code involved for the sheet you try to write to?

Holger
 
Upvote 0
Hi MarokOW,

why dio you use Value2 (I would have expected either Value or Text), what is the content you want to copy? Any code involved for the sheet you try to write to?

Holger
Value2 came from a spreadsheet I have been using successfully, Value gives the same error.
 
Upvote 0
Hi MarkOW,

in the version I use (Excel2019) the code supplied delivers the correct row to write to either without ListObject or with Listobject. As that may not be the cause for the error raised and you mentioned you have used a similar approach before and as you are the only person to give details on what differs between the original workbook and the one which causes the error: what is the content you try to put into the cell and are there any event codes being triggered in the actual workbook?

Maybe update your profile to show what Excel version you use on which platform (I don't have access to any newer versions on Windows nor to any on a Mac so I would be out of this).

Holger
 
Upvote 0
Hi MarkOW,

in the version I use (Excel2019) the code supplied delivers the correct row to write to either without ListObject or with Listobject. As that may not be the cause for the error raised and you mentioned you have used a similar approach before and as you are the only person to give details on what differs between the original workbook and the one which causes the error: what is the content you try to put into the cell and are there any event codes being triggered in the actual workbook?

Maybe update your profile to show what Excel version you use on which platform (I don't have access to any newer versions on Windows nor to any on a Mac so I would be out of this).

Holger
I ended up splitting my table into separate tables (1 column per ComboBox) and this solved my issue.
Thanks for your input
 
Upvote 0
Solution

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

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