Darkside  

Voltar   Darkside > Darkside > Comunidade
FAQ Calendário Postagens do dia Buscapé Search

Responder
 
Thread Tools
Never Ping
🌀 Trooper
 

Gamertag: Willian Braga PSN ID: Never_Ping XFIRE ID: neverping Steam ID: neverping
Default Visual Basic - help.

04-08-05, 11:20 #1
Vejam se podem ajudar

Eu estou criando uma macro em VBA para umas planilhas em Excel. Que pegue os valores dos chks e coloque caso Checado 1 ou 0 se tiver em branco.
Uma equipe do banco me passou essas planilhas com uns 3 checkboxes por Coluna e linha, alguns checados e outros nao.
So que o infeliz que fez essas planilhas, nao colocou 1 chk por Coluna, fez o favor de colocar 3 por linha e coluna.
Ai eu tive que oganizar os Chk por Top e Left por que o animal deve ter pego os checks de algum outro lugar e fikou colando na planilha, ai as caixinhas fikaram fora de ordem, so que descobri mais um problema, tem algumas planilhas que esses CHK estao, sobrepostos.
Entao como faço pra pegar so os CHK da FRENTE organizando-os ?
Lembrando que eu ja procurei na Help e talz.

Os chk estao posicionados assim.
Na coluna
- F -
chk chk chk - Linha 1
chk chk chk - Linha 2
chk chk chk - Linha 3
chk chk chk - Linha 4
E assim por diante


Essa Macro pega os valor dos Chk, joga numa outra planilha chamada TEMP, Ordena os dados e joga os dados ordenados de volta para a planilha correta.

Vou postar o Codigo ai tb

Codigo do FORM

Private Sub cmdprocessar_Click()
Dim SheetDestino As Integer
Dim SheetTemp As Integer

SheetTemp = 28

For f = 1 To Sheets.Count - 1
Label2.Caption = "Processando Planilha: " & Sheets(f).Name
DoEvents


SheetDestino = f

Call ApagaTemp(SheetTemp)
Call CopiaDadosdeOrigemparaTemp(SheetDestino, SheetTemp)
Call ordenaDadosTemporarios(SheetDestino, SheetTemp)
Call DevolveDadosparaoDestino(SheetDestino, SheetTemp)


Next f
Application.ScreenUpdating = True
MsgBox "Acabou !!!"


End Sub

Private Sub Frame3_Click()

End Sub





Codigo do Modulo

Sub CopiaDadosdeOrigemparaTemp(SheetDestino As Integer, SheetTemp As Integer)
'-------------------------------------------------------- Rotina para copiar os valores para o temp !
Application.ScreenUpdating = False

x = Sheets(SheetDestino).CheckBoxes.Count

For f = 1 To x
Sheets(SheetTemp).Cells(f, 1) = Sheets(SheetDestino).CheckBoxes(f).Top
Sheets(SheetTemp).Cells(f, 2) = Sheets(SheetDestino).CheckBoxes(f).Left
Sheets(SheetTemp).Cells(f, 3) = Sheets(SheetDestino).CheckBoxes(f).Value
Next f

End Sub

'2
Sub ordenaDadosTemporarios(SheetDestino As Integer, SheetTemp As Integer)
'------------------------------------------------------- Oedena o Temp pelas colunas Top e Left !!
Sheets(SheetTemp).Select
Columns("A:C").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

i = 1
While Sheets(SheetTemp).Cells(i, 2) <> ""
Range(Cells(i, 1), Cells(i + 2, 3)).Select
'Selection.Sort Key1:=Range(Cells(i, 1), Cells(i + 2, 3)), Order2:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

i = i + 3

Wend
End Sub



'3

Sub DevolveDadosparaoDestino(SheetDestino As Integer, SheetTemp As Integer)

'--------------------------------------------------------- Copia de Volta !!
f = 1
LinhaInicial = 1
ContLinhaTemp = LinhaInicial
ContLinhaDestino = 3



While Sheets(SheetTemp).Cells(ContLinhaTemp, 1) <> ""
'Sheets.CheckBoxes(f).Left

If Sheets(SheetTemp).Cells(ContLinhaTemp, 3) = 1 Then
Sheets(SheetDestino).Cells(ContLinhaDestino, 10) = 1
Else
Sheets(SheetDestino).Cells(ContLinhaDestino, 10) = 0
End If

If Sheets(SheetTemp).Cells(ContLinhaTemp + 1, 3) = 1 Then
Sheets(SheetDestino).Cells(ContLinhaDestino, 11) = 1
Else
Sheets(SheetDestino).Cells(ContLinhaDestino, 11) = 0
End If

If Sheets(SheetTemp).Cells(ContLinhaTemp + 2, 3) = 1 Then
Sheets(SheetDestino).Cells(ContLinhaDestino, 12) = 1
Else
Sheets(SheetDestino).Cells(ContLinhaDestino, 12) = 0
End If

ContLinhaDestino = ContLinhaDestino + 1
ContLinhaTemp = ContLinhaTemp + 3

Wend




End Sub

Sub ApagaTemp(SheetTemp As Integer)
Sheets(SheetTemp).Select
Columns("A:C").Clear
End Sub





Never Ping is offline   Reply With Quote
PIT BULL
Trooper
 

XFIRE ID: pitbull666br Steam ID: pitbull666br
04-08-05, 11:36 #2
Tira uma Screenshot pra ter uma noção melhor do seu problema.

PIT BULL is offline   Reply With Quote
ChakaN
Banned
 

04-08-05, 11:38 #3
jesus do ceu

se tu pudesse, seria mais facil me mandar a planilha

ChakaN is offline   Reply With Quote
Gabeleu
Trooper
 

PSN ID: GABELEU
04-08-05, 11:53 #4
 


Entao,
Esses CHK estao de 3 em 3...
So que tem alguns escondidos.. envezzz de 1 1 1 estao assim 2 2 2
Estao duplicados.
Preciso organizar eles pela frente pois ja foram organizados por TOP e LEFT

Gabeleu is offline   Reply With Quote
ChakaN
Banned
 

04-08-05, 11:58 #5
se ateh amanha de manha ninguem fizer
eu faco amanha de manha

ChakaN is offline   Reply With Quote
Gabeleu
Trooper
 

PSN ID: GABELEU
04-08-05, 11:59 #6
Nao veio, so me fala como que faço p pegar so os CHK da frente ???

Gabeleu is offline   Reply With Quote
Gabeleu
Trooper
 

PSN ID: GABELEU
04-08-05, 12:37 #7
Valeu Never, por abrir esse topico p mim !!!

Gabeleu is offline   Reply With Quote
ChakaN
Banned
 

04-08-05, 13:26 #8
ok

entao me diga o nome dos checks que tao em cada linha huhu
ou ta tudo com o mesmo nome sera?

eh o q mais preciso saber, o nome que estao

se eh apenas um vetor com trocentos check
ou se tem um vetor de 3 indices por linha

parece q o cara fez um vetor de checks por linha

ChakaN is offline   Reply With Quote
un4
inativo
 

04-08-05, 13:51 #9
auto it

un4 is offline   Reply With Quote
Gabeleu
Trooper
 

PSN ID: GABELEU
04-08-05, 14:30 #10
Quando esta com VALUE = 1 ele coloca 1 na planilha Quando VALUE = -4146 colca 0
TOP..LEFT..VALUE

14697,75 / 402 / -4146 3 valores desse corresponde a 1 linha com 3 Chks
14697,75 / 440,25 / -4146
14697,75 / 504,75 / -4146

8832,75 504,75 -4146
8845,5 402 -4146
8845,5 440,25 -4146
8845,5 504,75 1
8845,5 402 -4146
8845,5 440,25 -4146
8845,5 504,75 -4146
8858,25 402 -4146
8858,25 440,25 -4146
8858,25 504,75 1
8858,25 402 -4146
8858,25 440,25 -4146
8858,25 504,75 -4146
8871 402 -4146
8871 440,25 -4146
8871 504,75 1
8871 402 -4146
8871 440,25 -4146
8871 504,75 -4146
8883,75 402 -4146
8883,75 440,25 -4146
8883,75 504,75 1
8883,75 402 -4146
8883,75 440,25 -4146
8883,75 504,75 -4146
8896,5 402 -4146
8896,5 440,25 -4146
8896,5 504,75 1
8896,5 402 -4146
8896,5 440,25 -4146
8896,5 504,75 -4146
8909,25 402 -4146
8909,25 440,25 -4146
8909,25 504,75 1
8909,25 402 -4146
8909,25 440,25 -4146
8909,25 504,75 -4146
8922 402 -4146
8922 440,25 -4146
8922 504,75 1
8922 402 -4146
8922 440,25 -4146
8922 504,75 -4146
8934,75 402 -4146
8934,75 440,25 -4146
8934,75 504,75 1
8934,75 402 -4146
8934,75 440,25 -4146
8934,75 504,75 -4146
8947,5 402 -4146
8947,5 440,25 -4146
8947,5 504,75 1
8947,5 402 -4146
8947,5 440,25 -4146
8947,5 504,75 -4146
8960,25 402 -4146
8960,25 440,25 -4146
8960,25 504,75 1
8960,25 402 -4146
8960,25 440,25 -4146
8960,25 504,75 -4146
8973 402 -4146
8973 440,25 -4146
8973 504,75 1
8973 402 -4146
8973 440,25 -4146
8973 504,75 -4146
8985,75 402 -4146
8985,75 440,25 -4146
8985,75 504,75 1
8985,75 402 -4146
8985,75 440,25 -4146
8985,75 504,75 -4146
8998,5 402 -4146
8998,5 440,25 -4146
8998,5 504,75 1
8998,5 402 -4146
8998,5 440,25 -4146
8998,5 504,75 -4146
9011,25 402 -4146
9011,25 440,25 -4146
9011,25 504,75 1
9011,25 402 -4146
9011,25 440,25 -4146
9011,25 504,75 -4146
9024 402 -4146
9024 440,25 -4146
9024 504,75 1
9024 402 -4146
9024 440,25 -4146
9024 504,75 -4146
9036,75 402 -4146
9036,75 440,25 -4146
9036,75 504,75 1
9036,75 402 -4146
9036,75 440,25 -4146
9036,75 504,75 -4146
9049,5 402 -4146


Essa planilha ele esta acusando 6000 e poucos CHKs, so que nessa planilha so tem 3000.
Tem CHKs sobrepostos ai.

Nao coloquei todos pq o forum nao deixa


Last edited by Gabeleu; 04-08-05 at 14:35..
Gabeleu is offline   Reply With Quote
ChakaN
Banned
 

04-08-05, 14:42 #11
:/

virrgg !! desisto!!!

ChakaN is offline   Reply With Quote
Gabeleu
Trooper
 

PSN ID: GABELEU
04-08-05, 14:49 #12
Beleza, ja resolvi o problema...
Como tem 30 planilhas e so uma ta dando pau, meu chefe mandou eu exclui-la.

O cara que passou isso ai que vai se phoder tendo que fazer na mao !!!
uahuahauhauahua

Provavelmente uma Estagiaria Gostoza do Bradesco !!!
hehehehe

Gabeleu is offline   Reply With Quote
CroNicaL
Trooper
 

Steam ID: cron1cal
04-08-05, 16:54 #13
Apaga t udo e faz um direito que é + facil!

CroNicaL is offline   Reply With Quote
Bombastic
The Alpha Male
 

04-08-05, 19:57 #14
Quote:
Postado por un4
auto it
provavelmente uma das melhores coisas inventadas no mundo depois da ds

Bombastic is offline   Reply With Quote
Lev
Trooper
 

19-06-06, 11:46 #15
Aproveitando o topico pra nao criar outro... alguem me ajuda em vb tbm:

http://scriptbrasil.com.br/forum/ind...howtopic=79353

Lev is offline   Reply With Quote
Responder


Regras de postagem
Você não pode criar novos tópicos
Você não pode postar
Você não pode enviar anexos
Você não pode editar seus posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Atalho para Fóruns



O formato de hora é GMT -3. horário: 11:31.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.