Página 1 de 1

Busca de dados(Useform busca na planilha)

Enviado: 11 Mai 2016 às 15:48
por Kevim2013
Ao iniciar o userform preciso que ele puche informações da ultima celula da coluna B também da coluna C em variaveis separadas dadas UCD(Ultima célula Data) E UCM(Ultima Célula Mês)

No subscrito setei o w, como o Objeto(Plano), para facilitar formulas. Logo Após o selecionei o plano.
Para setar as ultimas celulas UCD e UCM, sendo assim o meu txtbox tomaria o "UCD.value" para sí(Iniciando com o valor da ultima data)

Código: Selecionar todos

'Variaveis que utilizei em geral
Dim UltDat As Range
Dim Data  As Range 
Dim UC As Range 
Dim w As Worksheet
Dim UCD As Range 
Dim UCM As Range 


txt_nome = "Tcc projeto Official"
TextBoxDate = Date
TextBoxDate.Enabled = False
TextBoxUltDat.Enabled = False
TextBoxUltMes.Enabled = False
TextBoxMes.Enabled = False
TextBoxMes = Format(Now, "mmmm")

'A partir daqui não funciona

Set w = Sheets("RegBackup")
w.Select
Set UCD = w.Range("$B$1000").End(xlUp).Select
Set UCM = w.Range("$C$1000").End(xlUp).Select
TextBoxUltDat = UCD.Value
TextBoxUltMes = UCM.Value


Re: Busca de dados(Useform busca na planilha)

Enviado: 11 Mai 2016 às 15:57
por Kevim2013
Desculpe faltou pedaços do código.
Código: Selecionar todos
Private Sub UserForm_Initialize()

Dim UltDat As Range
Dim Data  As Range
Dim UC As Range
Dim w As Worksheet
Dim UCD As Range
Dim UCM As Range

Set w = Sheets("RegBackup")
Set UCD = w.Range("$B$1000").End(xlUp).Select
Set UCM = w.Range("$C$1000").End(xlUp).Select

txt_nome = "Tcc projeto Official"
TextBoxDate = Date
TextBoxDate.Enabled = False
TextBoxUltDat.Enabled = False
TextBoxUltMes.Enabled = False
TextBoxMes.Enabled = False
TextBoxMes = Format(Now, "mmmm")

'A partir daqui não funciona

w.Select
TextBoxUltDat = UCD.Value
TextBoxUltMes = UCM.Value


End Sub