Advertisement
charlesdutton22

Convert Formula to Text

Mar 2nd, 2023
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 0.54 KB | Source Code | 0 0
  1. Private Sub E_ConvertToText()
  2.     Dim ws As Worksheet
  3.     Dim lastRow As Long
  4.     Dim i As Long
  5.    
  6.     ' Set worksheet to convert values in
  7.    Set ws = Worksheets("AssetScope")
  8.    
  9.     ' Find the last row in column G
  10.    lastRow = ws.Cells(ws.Rows.Count, "G").End(xlUp).Row
  11.    
  12.     ' Loop through rows in column G
  13.    For i = 2 To lastRow
  14.         ' Convert formula to value
  15.        ws.Range("G" & i).Value = ws.Range("G" & i).Value
  16.     Next i
  17.    
  18.     ' Convert column G to text format
  19.    ws.Range("G:G").NumberFormat = "@"
  20. End Sub
Tags: excel macro vbs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement