You are not logged in.

Dear visitor, welcome to Palo Community Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

ilianefeder

Professional

  • "ilianefeder" is female
  • "ilianefeder" started this thread

Posts: 15

Date of registration: May 4th 2010

  • Send private message

1

Wednesday, December 8th 2010, 10:46am

reset VB macro for all Palo Formulas

Hi,

I don't now, if this is the right topic for this. So if not please move it to the right place.

I have wrote a macro to reset all Palo Formulas in a sheet.
It helps if a user has destroy one or more Palo Formulas in the input aera.
The marco also looks for values in the cell and put it to the database. So aslo this get not lost.

I paste the macro here, because without the helf from the forum, it whould not exist ;-)
So thanks to all who have help me or had answer similar topics.
Maybe it is usefull for some others too.
Attantion: it is not perfect!! ...but it work ... ;-)

Here my code:


Sub All_Palo_Formel_reset()

'diese Macro geht Felder durch und prüft ob die Paloformel noch stimmt.
'this marco resets all Palo DATAC Formulas
'ist eine Paloformel fehlerhaft
'it also correct wrong formulas
' wird der Wert aus der Zelle in der Datenbank abgelegt und die Palo Formel wieder hergestellt.
'the value from the cell is written to the database


Dim strcoll_letter As String 'Spalte als Buchstabe, coloumn as letter
Dim strformel As String 'Paloformel für die Zelle
Dim intzeile As Integer 'aktuelle Zeile als integer, actual row as integer
Dim wert As Variant 'wert aus der Zelle, value from the cell
Dim strzelle As String 'zellennamen als string z.B. E30, cellname
Dim alteformel As String 'Formel die aktuell in der Zelle, actual formula
Dim varhelp As Variant 'help variable
Dim arraycol As Variant
Dim vonzeile As Integer 'first row from the Palo input area
Dim biszeile As Integer 'last row of the Palo input formula


'coloums thar shoudl be proved, coloums with Palo input formuals
arraycol = Array("E", "Y", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BC", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BM", "BN", "BO", "BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX")

vonzeile = 31 'erste Zeile mit Palo Formeln, first row input area
biszeile = 54 ' letzte Zeile mit Palo Formeln, last row input area
strcoll_letter = "E" 'start position (nicht unbedingt nötig)
'ACHTUNG beim anpassen den Macros muß der Index der Titelzeile (hier 30) und der Namensspalte (hier C) noch angepasst werden.
'Attantion: in this example C is the column with the Palo row-names, it has to be modified in other sheets and here is 30 the row with the coloumn names, that also has to be modified

For s = LBound(arraycol) To UBound(arraycol) 'den array durchlaufen
strcoll_letter = arraycol(s)
For i = vonzeile To biszeile

intzeile = i
'die richtige Formel zusammen setzen:
'bulid the formula (here is 30 and C !! and YOUR Dimensons )
strformel = "=PALO.DATAC($A$1;$A$2;$A$3;$A$4;$A$5;$A$6;$C" & CStr(intzeile) & ";" & strcoll_letter & "$30)"
'Die Zellbeizeichnung:
'cell name:
strzelle = strcoll_letter & CStr(intzeile)
'Formel aus der Zelle
'actual formula from the cell:
alteformel = Range(strzelle).FormulaLocal
'Vergleich aktuelle Formel und die richtige Formel:
'comparing right and actual Palo Formula:
If (alteformel <> strformel) Then ' there is a mistake in the actual formula or it is missing

'den Wert aus der Zelle in die Palo Datenbank übertragen:
'save the value from the cell in the database:
wert = Range(strzelle).Value
' here also look at YOUR dimensions and names row and names coloumn:
varhelp = Application.Run("PALO.SETDATA", wert, False, Range("A1").Value, Range("A2").Value, Range("A3").Value, Range("A4").Value, Range("A5").Value, Range("A6").Value, Range("C" & CStr(intzeile)).Value, Range(strcoll_letter & "30").Value)
'die alte Paloformel wieder herstellen
'reset the Palo formula
Range(strzelle).FormulaLocal = strformel

End If
Next i 'nächste zeile, next row
Next s
Worksheets("Eingabe").Calculate ' calulate the sheet

'Erfolgsmeldung, happy ending message:
MsgBox ("Alle Paloformeln im Eingabebereich wurden wieder hergestellt.")

End Sub

best wishes,
Karen

This post has been edited 1 times, last edit by "ilianefeder" (Dec 8th 2010, 10:47am)


  • "h_decker" is male

Posts: 763

Date of registration: Oct 26th 2005

Location: Cologne, Germany

  • Send private message

2

Wednesday, December 8th 2010, 11:41am

RE: reset VB macro for all Palo Formulas

Hi Karen,
thanks for the code.

There is another possibilty by disabling the delete key.

In the module "ThisWorkbook" (Diese Arbeitsmappe) paste the following code:


Private Sub Workbook_Open()
Application.OnKey "{DEL}", "doNothing"
End Sub

It will be exectuted when opening the workbook.

Then in another module paste the following (empty) sub:

Public Sub doNothing()

End Sub


This will disable DEL-Key in Excel. To activate it again use the following code:

Application.OnKey "{DEL}"

Holger

ilianefeder

Professional

  • "ilianefeder" is female
  • "ilianefeder" started this thread

Posts: 15

Date of registration: May 4th 2010

  • Send private message

3

Wednesday, December 8th 2010, 11:57am

Thank for the addion :-)

My users have a lot of fantasy to destroy or change my Palo Forumlas and i'm not every day in office.
The macro is the "help yourself" solution additional to all other potection ;-)

best wishes,
Karen

AvdBerg

Professional

  • "AvdBerg" is male

Posts: 19

Date of registration: Apr 9th 2010

Location: Netherlands

Occupation: Sr. Planning Analyst

  • Send private message

4

Friday, December 10th 2010, 4:06pm

Holger,

Thanks for the info.

In addition, if you use the following code in doNothing; the cell value will only not be deleted if the formula starts with "=PALO":

Public Sub doNothing()
If ActiveCell.HasFormula And Left(ActiveCell.Formula, 5) = "=PALO" Then
Else
ActiveCell.Value = vbNullString
End If

End Sub
Kind regards,

Arthur van den Berg

Rate this thread