how do I extract text from a validation list

kmillanr

New Member
Joined
Jul 30, 2015
Messages
24
hello,

I'm trying to extract the string or text inside a validation data list that is in cell H13 and copy or place the data in another workbook at the specified range. this is my code:

Option Explicit

Private Sub BotonCrearTxt()
Dim filepath As String
Dim name As ListBox
Dim sueldo As Integer
Dim wbpaladin As Workbook
Dim sheetpagos As Worksheet
Dim last_row_data As Variant

Set sheetpagos = Sheets("pagos")
sheetpagos.Select
name = Range("H13")<----------THIS RANGE IS A VALIDATION DATA LIST
sueldo = Range("J13")
Set wbpaladin = Workbooks.Open("C:\Users\Kevin Millan\Dropbox\PALADIN\INVENTARIO REPUESTOS.xlsm")
Sheets("GASTOS").Select
last_row_data = Sheets("GASTOS").Range("H60000").End(xlUp).Row
last_row_data = last_row_data
Sheets("GASTOS").Range("h" & last_row_data) = name
Sheets("GASTOS").Range("j" & last_row_data) = sueldo

end sub

ps: after that i'd like to add an amount of rows in my new otherworkbook table that would be equal to the amount of rows added from my previous workbook. (i know that for that I would have to make my ranges dynamic, which I can figure out).

thank you
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You'll need to loop through the items in the validation list. Something like the following might help you...

Code:
Sub loopthroughvalidationlist()
Dim inputRange As Range
Dim c As Range
Set inputRange = Evaluate(Range("H13").Validation.Formula1)
For Each c In inputRange
    '... do something with c.Value
Next c
End Sub

Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

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