SHARE
TWEET

Untitled

a guest Apr 25th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Nummerserie()
  2.     Dim cell As range
  3.     Set cell = ActiveCell
  4.     Dim n As Integer
  5.     n = InputBox("Skriv det sidste nummer", "Nummerserie")
  6.     Dim i As Integer
  7.     For i = 1 To n
  8.         cell.Value = i
  9.         Set cell = cell.Offset(1, 0)
  10.     Next i
  11.  
  12. End Sub
  13.  
  14.  
  15. Sub VbaPdf()
  16.     Dim i As Integer
  17.     For i = 1 To Worksheets.Count
  18.         If Worksheets(i).Name = "Start" Then
  19.             'Vi vil ikke printe Start
  20.         Else
  21.             Worksheets(i).ExportAsFixedFormat Type:=xlTypePDF, FileName:=Application.ActiveWorkbook.Path & "/" & Worksheets(i).Name & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
  22.         End If
  23.     Next i
  24. End Sub
  25.  
  26.  
  27. Sub CSVImport()
  28.     Dim FileName As String
  29.     Dim LastRow As Integer
  30.  
  31.     ' Valg af fil
  32.     With Application.FileDialog(msoFileDialogFilePicker)
  33.     If .Show <> 0 Then
  34.             FileName = .SelectedItems(1)
  35.  
  36.         End If
  37.     End With
  38.    
  39.     'Vi finder sidste række
  40.     LastRow = Worksheets("Data").cells(Worksheets("Data").Rows.Count, "A").End(xlUp).Row
  41.     If LastRow <> 1 Then LastRow = LastRow + 1
  42.  
  43.     'Importering
  44.     Sheets("Data").Select
  45.     With ActiveSheet.QueryTables.Add(Connection:= _
  46.         "TEXT;" & FileName, Destination:=range("A" & LastRow))
  47.         .Name = FileName
  48.         .FieldNames = True
  49.         .RowNumbers = False
  50.         .FillAdjacentFormulas = False
  51.         .PreserveFormatting = True
  52.         .RefreshOnFileOpen = False
  53.         .RefreshStyle = xlInsertDeleteCells
  54.         .SavePassword = False
  55.         .SaveData = True
  56.         .AdjustColumnWidth = True
  57.         .RefreshPeriod = 0
  58.         .TextFilePromptOnRefresh = False
  59.         .TextFilePlatform = 850
  60.         .TextFileStartRow = 2
  61.         .TextFileParseType = xlDelimited
  62.         .TextFileTextQualifier = xlTextQualifierDoubleQuote
  63.         .TextFileConsecutiveDelimiter = False
  64.         .TextFileTabDelimiter = False
  65.         .TextFileSemicolonDelimiter = True
  66.         .TextFileCommaDelimiter = False
  67.         .TextFileSpaceDelimiter = False
  68.         .TextFileColumnDataTypes = Array(1, 1, 1, 1)
  69.         .TextFileTrailingMinusNumbers = True
  70.         .Refresh BackgroundQuery:=False
  71.     End With
  72.  
  73.     'Fjern 0 værdier + Indsæt formel
  74.     range("A" & LastRow).Select
  75.     Do Until ActiveCell.Value = ""
  76.         If ActiveCell = 0 Then
  77.             ActiveCell.EntireRow.Delete 'Vi fjerner rækken
  78.         Else
  79.         'Indsæt formel
  80.             ActiveCell.Offset(0, 6).Formula = "=F" & ActiveCell.Row & "*E" & ActiveCell.Row
  81.             ActiveCell.Offset(1, 0).Select 'Vi offseter en celle ned
  82.         End If
  83.     Loop
  84.     range("A1").Select
  85.     range(Selection, Selection.End(xlToRight)).Select
  86.     range(Selection, Selection.End(xlDown)).Select
  87. End Sub
  88.  
  89. Sub ChartResize()
  90.     Dim chart As ChartObject
  91.     For Each chart In Sheets("Diagram").ChartObjects
  92.         chart.Height = 200
  93.         chart.Width = 300
  94.     Next
  95. End Sub
  96.  
  97. Sub ColourizeMarch()
  98.     Dim rng As range, cell As range
  99.     Dim LastRow As Integer
  100.    
  101.     Sheets("Data").Select
  102.     'Vi finder sidste række
  103.     LastRow = Worksheets("Data").cells(Worksheets("Data").Rows.Count, "C").End(xlUp).Row
  104.     Set rng = ActiveSheet.range("C1:C" & LastRow)
  105.    
  106.     'Vi kører gennem cellerne og hvis Month(celleVærdi) returnerer 3 (dvs. marts) ændrer vi format
  107.     For Each cell In rng
  108.         If Month(cell.Value) = 3 Then
  109.             With cell
  110.                 .Interior.Color = vbBlue
  111.                 .Font.Bold = True
  112.                 .Font.Color = vbWhite
  113.             End With
  114.         End If
  115.     Next cell
  116. End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top