Skip to content

Instantly share code, notes, and snippets.

@hashrock
Created April 11, 2013 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashrock/5364045 to your computer and use it in GitHub Desktop.
Save hashrock/5364045 to your computer and use it in GitHub Desktop.
Private Sub CommandButton1_Click()
Dim i As Long
Dim outFile As String
Dim hashSheet As Worksheet
hashSheet = ActiveSheet
Workbooks.Open Filename:=ThisWorkbook.Path & "\template.xls"
For i = 1 To ActiveSheet.UsedRange.Rows.Count
Dim key As String
Dim val As String
key = Cells(1, i).Value
val = Cells(2, i).Value
Cells.Replace What:=key, Replacement:=val, LookAt:=xlPart
Next i
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & outFile
ActiveWorkbook.Close
Debug.Print Cells(1, i).Value & " - " & Cells(2, i).Value
' For Each r In ActiveSheet.UsedRange.Rows
' Debug.Print "---"
' For Each c In r.Columns
' Debug.Print c.Value
' Next
' Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment