Advertisement
Guest User

template

a guest
Nov 14th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub ClearData()
  2. '
  3. ' ClearData Makro
  4. '
  5.    Dim answer As Integer
  6.     answer = MsgBox("Are you sure you want to empty the sheet?", vbYesNo + vbQuestion, "Empty Sheet Data")
  7.     If answer = vbYes Then
  8.         With ActiveSheet.ListObjects(1)
  9.             If Not .DataBodyRange Is Nothing Then
  10.                 .DataBodyRange.ClearContents
  11.                 .DataBodyRange.Delete
  12.             End If
  13.         End With
  14.     End If
  15. End Sub
  16.  
  17. Sub CopyTemplate()
  18. '
  19. ' CopyTemplate Makro
  20. '
  21.    Dim title As Variant
  22.     title = InputBox("Give me new sheet name")
  23.     If title <> "" Then
  24.         ActiveSheet.Copy After:=Sheets(Sheets.Count)
  25.         ActiveSheet.Name = title
  26.     End If
  27. End Sub
  28.  
  29. Sub AddBuy()
  30. '
  31. ' AddNewLine Makro
  32. '
  33.    Set myNewRow = ActiveSheet.ListObjects(1).ListRows.Add
  34.     myNewRow.Range.Cells(1).Value = Date
  35.     myNewRow.Range.Cells(2).FormulaR1C1 = "=RC[-1]+90"
  36.     myNewRow.Range.Cells(6).FormulaR1C1 = "=IF(RC[-3]>0,RC[-3],IF(RC[-1]>0,R[-1]C-RC[-1],""""))"
  37.     myNewRow.Range.Cells(3).Select
  38. End Sub
  39.  
  40. Sub AddSell()
  41. '
  42. ' AddPoraba Makro
  43. '
  44.    Cells(ActiveCell.Row, 2).Select
  45.     If IsDate(ActiveCell) Then
  46.        
  47.         Dim ok As Boolean
  48.         ok = True
  49.        
  50.         Dim last As Integer
  51.         last = ActiveSheet.ListObjects(1).ListColumns(1).Range.Rows.Count + 1
  52.        
  53.         Do While ok
  54.             ActiveCell.Offset(1, 0).Select
  55.             If ActiveCell.Row > last Then
  56.                 ok = False
  57.             End If
  58.             If IsDate(ActiveCell) Then
  59.                 ok = False
  60.             End If
  61.         Loop
  62.        
  63.         If ActiveCell.Row > last Then
  64.             Set myNewRow = ActiveSheet.ListObjects(1).ListRows.Add
  65.         Else
  66.             ActiveCell.EntireRow.Insert
  67.         End If
  68.        
  69.         Set newRow = ActiveCell.EntireRow
  70.         newRow.Cells(5).Value = Date
  71.         newRow.Cells(3).ClearContents
  72.         newRow.Cells(7).FormulaR1C1 = "=IF(RC[-3]>0,RC[-3],IF(RC[-1]>0,R[-1]C-RC[-1],""""))"
  73.         newRow.Cells(6).Select
  74.        
  75.     Else
  76.         MsgBox "Select row With Buy Items"
  77.     End If
  78.        
  79. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement