Auto update column when ComboBox selection is made

RobertEnglish

New Member
Joined
Nov 25, 2013
Messages
8
I've been putting together a macro that reads in cells from one specific row on <CODE>Sheet1</CODE> and places them onto a ComboBox on a <CODE>Sheet2</CODE>

<CODE>|cellA | cellB | cellC | cellD | ... |cellZ | </CODE>

</PRE>Once loaded to the ComboBox, whatever cell is selected there has it's column copied to a column on <CODE>Sheet2</CODE>.
So far I have been able to do this manually but I need it do automatically update from any changes made to the row and when a selection is made in the ComboBox.
Here's my code so far:

Option Explicit
Sub ComboBox1_Change_Open()

Dim cmbx As ComboBox
Dim myRange As Range
Dim i As Integer
Dim c As Range
Set cmbx = Sheet7.ComboBox1
cmbx.Clear
Set myRange = ActiveWorkbook.Sheets("1. Process information").Range("C4:Z4")
For Each c In myRange
If c.Value <> "" Then
cmbx.AddItem c.Value
cmbx = cmbx.Column(0, 0)

End If
Next

For i = 0 To cmbx.ListCount
If cmbx.ListIndex = i Then
With Sheets("1. Process information")
.Range(.Cells(4, i + 4), .Cells(Rows.Count, i + 4).End(xlUp)).Copy
End With
ActiveWorkbook.Sheets("Shipsheet").AutoFill.Paste Destination:=Sheets("Shipsheet").Range("B4")
End If
Next i

End Sub

Just realised this code only works when <CODE>ListIndex</CODE> is 0 and that <CODE>ListIndex</CODE> is not the right function to use. This had worked for the first item in the ComboBox.

(I'm using Microsoft Excel 2007)
Any help is appreciated. Thanks in advance
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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