Existing user? Sign in
Sign up
Games
Servers
Useful
User
Pass
2FA
Excel Visual Basic for Applications (VBA) help
Freakz Forum Index
->
Trash Bin
->
Trash
->
Programming / Scripting / Database
Author
Message
2226
Pufarinaa
[Arch Druid]
Status: Offline
(since 23-02-2023 22:39)
Joined: 28 Apr 2011
Posts: 587
,
Topics: 25
Location:
Bucharest
Reputation:
492.1
Votes
: 37
Posted: 23-05-2013, 17:43:52
| Translate post to:
... (
Click for more languages
)
Am creat niste liste cu ajutorul optiunii de data validation.
Exemplu:
In celula 1 pot selecta din drop-dowm list: Item1, Item2, Item3, Item4
Daca in celula 1 am selectat Item1, in celula 2 o sa apara un drop-down list cu urmatoarele optiuni: Crit, Hit, NONE
Daca in celula 1 am selectat Item2, in celula 2 o sa apara un drop-down list cu urmatoarele optiuni: Mastery, Haste, NONE
Acum intervine problema. Daca in celula 1 am selectat Item1 si in celula 2 am selectat Crit, atunci cand selectez in celula 1 Item2, in celula 2 o sa ramana Crit, dar daca apas pe sagetuta sa apara lista, optiunile vor fi de: Mastery, Haste, NONE.
Vreau ca atunci cand selectez alt item in celula 1, celula 2 sa se reseteze automat la valoarea NONE. Am inteles ca acest live update se poate face doar printr-un cod in VBA.
Am cautat pe net cum sa fac acest lucru si nu am gasit, asa ca intreb si aici. Din cate am observat VBA e ca si programarea in C++ si eu nu ma pricep deloc la programare, dar as vrea sa invat.
Daca ma poate si are timp cineva sa ma ajute cu aceasta problema as fi foarte recunoscator. O sa ma mai documentez in continuare si pe net, poate nu am cautat destul de bine.
V-am lasat si un video ca sa intelegeti mai bine problema.
https://youtube.com/watch?v=D1IrmMquakg:
0
0
Back to top
koltzu
[Banned user]
Status: Offline
(since 24-10-2013 15:18)
Joined: 24 Oct 2006
Posts: 6632
,
Topics: 170
Location:
Romania
Reputation:
847.9
Votes
: 94
Posted: 23-05-2013, 19:42:58
| Translate post to:
... (
Click for more languages
)
Reseteaza ambele celule de fiecare data cand alegi alt item, pune-le NONE sau ceva.
0
0
Back to top
Pufarinaa
[Arch Druid]
Status: Offline
(since 23-02-2023 22:39)
Joined: 28 Apr 2011
Posts: 587
,
Topics: 25
Location:
Bucharest
Reputation:
492.1
Votes
: 37
Posted: 23-05-2013, 19:49:39
| Translate post to:
... (
Click for more languages
)
Pai nu vreau sa le resetez eu manual, vreau sa se reseteze ele automat cand in celula 1 este selectat alt item.
0
0
Back to top
koltzu
[Banned user]
Status: Offline
(since 24-10-2013 15:18)
Joined: 24 Oct 2006
Posts: 6632
,
Topics: 170
Location:
Romania
Reputation:
847.9
Votes
: 94
Posted: 23-05-2013, 19:54:39
| Translate post to:
... (
Click for more languages
)
/facepalm
Pai eu ce ziceam? Reseteaza-l din cod, vezi ca trebuie sa aiba un event onChange sau ceva care-ti creeaza o functie, acolo pui sa aleaga NONE
0
0
Back to top
Pufarinaa
[Arch Druid]
Status: Offline
(since 23-02-2023 22:39)
Joined: 28 Apr 2011
Posts: 587
,
Topics: 25
Location:
Bucharest
Reputation:
492.1
Votes
: 37
Posted: 23-05-2013, 20:10:03
| Translate post to:
... (
Click for more languages
)
Pai asta zic, ca nu stiu cum sa il resetez din cod.
Deci sa explic iar, am facut asa:
2 celule, ambele cu data validation si am selectat list
In prima celula am asa: =GearHead
GearHead cuprinde itemele: Head1, Head2, Head3, Head4
In a doua celula am asa:
=(IF(OR(A35=Head1,A35=Head2), ReforgeMH,IF(A35=Head3,ReforgeMC, IF(A35=Head4,ReforgeH,ReforgeNone))))
A35 fiind a 2-a celula
ReforgeMH cuprinde optiunile: Mastery, Haste, NONE
Reforge MC cuprinde optiunile: Mastery, Crit, NONE
ReforgeH cuprinde optiunile: Haste, NONE
ReforgeNone cuprinde optiunea: NONE
Acum nu stiu ce cod sa scriu ca atunci cand in GearHead este selectat alt item, optiunile din celula 2 sa fie resetate la "NONE"
Am citit pe net ca se face dand click dreapta pe sheet-ul respectiv -> code -> si in VB sa fie scris nush ce cod. Ei bine eu nu stiu cum sa scriu acel cod ca sa se reseteze optiunile la NONE.
0
0
Back to top
Pufarinaa
[Arch Druid]
Status: Offline
(since 23-02-2023 22:39)
Joined: 28 Apr 2011
Posts: 587
,
Topics: 25
Location:
Bucharest
Reputation:
492.1
Votes
: 37
Posted: 23-05-2013, 22:11:27
| Translate post to:
... (
Click for more languages
)
Am gasit acest cod care imi functioneaza:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A35")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Range("C37") = "NONE"
Range("F37") = "NONE"
Range("C38") = "NONE"
Range("C39") = "NONE"
Range("C40") = "NONE"
Application.EnableEvents = True
End Sub
Cand valoare din A35 se schimba, atunci in celulele C37, F37, C38, C39, C40 se schimba.
Stie cineva cum fac sa imi apara la fel si pentru celula A45 si alte celule?
Am incercat sa scriu sub codul de mai sus, acest cod:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A45")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Range("C47") = "NONE"
Range("F47") = "NONE"
Range("C48") = "NONE"
Application.EnableEvents = True
End Sub
Dar imi da eroarea: "Compile error: Ambigous name detected: Worksheet_Change"
Daca schimb numele la Worksheet_Change nu imi functioneaza.
Inseamna ca mai trebuie sa bag inca un If pentru celula A45 in formula de sus, dar nu stiu unde
0
0
Back to top
Pufarinaa
[Arch Druid]
Status: Offline
(since 23-02-2023 22:39)
Joined: 28 Apr 2011
Posts: 587
,
Topics: 25
Location:
Bucharest
Reputation:
492.1
Votes
: 37
Posted: 24-05-2013, 12:22:27
| Translate post to:
... (
Click for more languages
)
Am gasit o solutie pana la urma:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$35" Then
Application.EnableEvents = False
Range("C37, F37, C38:C40") = "NONE"
Application.EnableEvents = True
End If
If Target.Address = "$A$45" Then
Application.EnableEvents = False
Range("C47, F47, C48") = "NONE"
Application.EnableEvents = True
End If
If Target.Address = "$A$53" Then
Application.EnableEvents = False
Range("C55, F55, C56:C58") = "NONE"
Application.EnableEvents = True
End If
End Sub
You can close this topic.
0
0
Back to top
Freakz Forum Index
->
Trash Bin
->
Trash
->
Programming / Scripting / Database
The time now is 29-11-2024, 05:49:28
Copyright info
Based on phpBB
ro
/
com
B
Login
I forgot my password
World of Warcraft
Login for more...
Download WoW 7.3.5
Misc
eSports
Achievements
Buy reputation with votes
Reputation trades
Forum rules
Ban list
Members list
User guide (FAQ)
World of Warcraft
View details