Buon dì, vorrei che dopo SOLO aver cambiato il valore di una cella nel foglio1 un pulsante nel foglio2 diventi eseguibile , chiedo suggerimenti
Io ho trovato questa macro che ho abbinato all'evento nel foglio1 ma non sò dove mettere/scrivere i parametri per controllare il pulsante nel foglio 2
Sub evento(Target)
If NOT Target.supportsService("com.sun.star.sheet.SheetCell") then exit sub
Sh = Target.getSpreadsheet()
addr = Target.getCellAddress()
rng = sh.getCellRangeByName("B2")
range2 = rng.queryintersection(Target.rangeaddress())
If range2.RangeAddressesAsString = "" Then
Exit Sub
Pulsante()
Else
print "cella F13 modificata in " & rng.string
End if
End Sub
Ultima modifica di ferro0099 il domenica 24 luglio 2022, 14:54, modificato 1 volta in totale.
Sarebbe utile un file di esempio, comunque nella macro che gestisce l'evento potresti modificare una cella del foglio2 scrivendoci per es. ATTIVA, nella macro che deve essere eseguita dal pulsante metti un IF che fa proseguire soltanto se nella cella c'è scritto ATTIVA
-------------------
Libre Office 7.5.3.2 su Windows 11
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
nel foglio uno , il cambiamento è sulla cella "B2" e il pulsante che dovrebbe essere disattivo e attivarsi solo al cambiamento della cella "B2" del foglio uno è quello nel secondo foglio "grigio"
... Il problema sussiste in quanto quando importo il file nel foglio 1 che è un CSV , nella cella "B2" mi viene scritto il nome del cliente , ma in realtà me lo importa come valore infatti se eseguo la macro con il PULSANTE nel foglio 2 per il salvataggio mi dà l'errore .... invece se riscrivo il nome del cliente sulla cella "B2" la macro funziona correttamente
Ultima modifica di ferro0099 il domenica 24 luglio 2022, 14:54, modificato 1 volta in totale.
Sub evento(Target)
If NOT Target.supportsService("com.sun.star.sheet.SheetCell") then exit sub
doc = Thiscomponent
Sh = Target.getSpreadsheet()
addr = Target.getCellAddress()
rng = sh.getCellRangeByName("B2")
range2 = rng.queryintersection(Target.rangeaddress())
If range2.RangeAddressesAsString = "" Then
Exit Sub
Else
Doc.Sheets(1).getCellRangeByName("AA1").String = "ATTIVA"
'print "cella B2 modificata in " & rng.string
End if
End Sub
sub SalvaPRE
Dim Doc As Object
Dim Sheet As Object
Dim SheetC As Object
'prepara il range da esportare:
Dim Data as Object
Dim DataN as Date, DateLong as Long, dDate as Object
Dim mFilterData(0) As New com.sun.star.beans.PropertyValue
Dim Adate as date
Doc = ThisComponent '<<<<<<<<<
Sheet = Doc.Sheets(0)
SheetC = Doc.Sheets(1)
If SheetC.getCellRangeByName("AA1").String = "" then exit sub ' <<<<<<<
SheetC.getCellRangeByName("AA1").String = "" ' <<<<<<<<<<<<<<<<
oRng = SheetC.getCellRangeByName("B2:Q27")
Cliente = SheetC.getCellRangeByName("E4").String
NumLotto =Sheet.getCellRangeByName("B4").Value
------
-------------------
Libre Office 7.5.3.2 su Windows 11
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
Sub evento(Target)
If NOT Target.supportsService("com.sun.star.sheet.SheetCell") then exit sub
doc = Thiscomponent
Sh = Target.getSpreadsheet()
addr = Target.getCellAddress()
rng = sh.getCellRangeByName("B2")
range2 = rng.queryintersection(Target.rangeaddress())
If range2.RangeAddressesAsString = "" Then
Exit Sub
Else
Form = Doc.Sheets(1).DrawPage.Forms.getByName("Formulario")
Button = Form.getByName("Pulsante 1")
Button.enabled=True
End if
End Sub