Guest User

Untitled

a guest
May 18th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.15 KB | None | 0 0
  1. Option Explicit
  2.  'this line makes it cap insensitive in your string selection
  3. Option Compare Text
  4.  
  5. Sub Check_Values_1()
  6.     On Error Resume Next
  7.      
  8.     Dim CurCell As Range
  9.     Dim Heading As String
  10.     Dim Prompt As String
  11.     Dim Criteria As Variant
  12.     Dim Color As Long
  13.      
  14.      
  15.     Dim lRows As Long
  16.     Dim lCols As Long
  17.     Dim lAllCells As Long
  18.     Dim a As Integer
  19.    
  20.     lRows = ActiveSheet.Rows.Count
  21.     lCols = ActiveSheet.Columns.Count
  22.     lAllCells = lRows * lCols
  23.      
  24.      '   Ensure that that the entire sheet was not selected
  25.      '   This would slow the loop down considerably
  26.     If Selection.Cells.Count = lAllCells Then
  27.         MsgBox "To check the entire sheet, please select only one cell", 64
  28.         Exit Sub
  29.     End If
  30.    
  31.      
  32.      ' Loop through each cell in the selection and color
  33.      ' as desired
  34.     If Selection.MergeArea.Cells.Count > 1 Then
  35.         For Each CurCell In Selection
  36.             a = a + 1
  37.             CurCell.Value = a
  38.             MsgBox (a)
  39.         Next CurCell
  40. '    Else
  41. '        For Each CurCell In ActiveSheet.UsedRange
  42. '             'If you don't make a selection, it checks all cells on the sheet with values
  43. '            If CurCell.Value = Criteria Then CurCell.Interior.ColorIndex = Color
  44. '        Next CurCell
  45.   End If
  46. End Sub
  47. Sub HYNTA()
  48. Dim i As Long
  49. For i = 1 To 2
  50.   MsgBox Cells(i, 1).MergeArea.Cells(1, 1).Value & " - " & Cells(i, 2).Value
  51. Next i
  52. End Sub
  53. Sub NewHYNT()
  54.  Dim rngToCheck As Range, rngCell As Range, rngChecked As Range, a As Integer
  55.  
  56.     Set rngToCheck = Selection
  57.    
  58.     If rngToCheck.Count > 1 Then
  59.     Set rngChecked = [IV65000]
  60.     For Each rngCell In rngToCheck.Cells
  61.    If Not rngCell.MergeCells Then
  62.      a = a + 1
  63.             rngCell.Value = a
  64.             MsgBox (a)
  65.    
  66.    ElseIf rngCell.MergeCells Then
  67.             If Intersect(rngCell, rngChecked) Is Nothing Then
  68.              a = a + 1
  69.             rngCell.Value = a
  70.             MsgBox (a)
  71.                 rngCell.Select
  72.                 Set rngChecked = Union(rngChecked, rngCell.MergeArea)
  73.                
  74.             End If
  75.         End If
  76.     Next rngCell
  77.    
  78.      
  79.    
  80.         End If
  81. End Sub
  82.  
  83.  
  84.  
  85. Sub seltable()
  86. '
  87. ' seltable Ìàêðîñ
  88. '
  89. ' Ñî÷åòàíèå êëàâèø: Ctrl+o
  90.  
  91.     If TypeName(Selection) <> "Range" Then Exit Sub
  92.     On Error Resume Next
  93. '   Check the cells with constants
  94.     For Each cell In Selection.SpecialCells(xlConstants, 23)
  95.         If cell.Value < 0 Then cell.Font.Bold = True Else cell.Font.Bold = False
  96.     Next cell
  97. '   Check the cells with formulas
  98.     For Each cell In Selection.SpecialCells(xlFormulas, 23)
  99.         If cell.Value < 0 Then cell.Font.Bold = True Else cell.Font.Bold = False
  100.     Next cell
  101.  
  102. End Sub
  103. Sub wordgo()
  104.  
  105. Dim wordApp As Object
  106.  
  107. Set wordApp = GetObject(, "Word.Application")
  108.  
  109. Selection.Copy
  110. wordApp.Selection.PasteSpecial Link:=True, DataType:=20, Placement:=wdInLine, DisplayAsIcon:=False
  111. End Sub
  112.  
  113.  
  114. Sub rang()
  115. Dim r As Range
  116. For n = 1 To r.Rows.Count
  117.     If r.Cells(n, 1) = r.Cells(n + 1, 1) Then
  118.         MsgBox "Duplicate data in " & r.Cells(n + 1, 1).Address
  119.     End If
  120. Next n
  121. End Sub
Add Comment
Please, Sign In to add comment