Here is what I came up with. The macro will color the text in the cell white or black depending...
Please try this as well. Sub Save2PDF() Dim Fname As String Fname = InputBox("Enter file name to save", "Save as...
Here is a simple copy and paste from cell A1 to D1 using vba Sub cpy() Range("A1").Copy Destination:=Range("C1") End Sub
I did not write this code but I think that it may help you. For more information about this code...
Hello Can you upload sample of your workbook?
Hi, Thanks for the reply. I need to find a formula for finding the column number, i can't give a...
Not sure if this will help. When you save your file click Tools>General Options and then click on Always create...
Sheet1 column "A" must have at least 2 rows (Cells A1 and A2) of data for macro to work. Less...
I have tested the following code for any input and it works fine.
Dim iRow As Long, iChar As Integer, Char1 As String, Char2 As Boolean, Char3 As String
For iRow = 1 To 10
For iChar = 1 To Len(Cells(iRow, 1)) - 3
Char1 = Mid$(Cells(iRow, 1), iChar, 1)
Char2 = IsNumeric(Mid$(Cells(iRow, 1), iChar + 1, 3))
Char3 = Mid$(Cells(iRow, 1), iChar + 4, 1)
If Char1 = "D" And Char2 = True Then
If Char3 = "F" Then
Cells(iRow, 2) = Mid$(Cells(iRow, 1), iChar, 5): Exit For
Cells(iRow, 2) = Mid$(Cells(iRow, 1), iChar, 4): Exit For
As you can see in the picture below, the string in column B is the output of my code and in column C is the output of PNRao’s code.
Here is an alternative code. Since I don’t know your layout data, it’s hard for me to put sub routine InsertColumnDate and RemoveColumnDate in a single program. So you have to run these two sub-routines alternately, just make sure you run sub-routine InsertColumnDate first and RemoveColumnDate afterward.
Dim StartDate As Date, EndDate As Date, Days As Integer, iDay As Integer
StartDate = "1/1/2016"
EndDate = "1/5/2016"
Days = EndDate - StartDate
Columns("A").Resize(, Days + 1).EntireColumn.Insert 'Change the Columns("A") accordingly
For iDay = 0 To Days
Cells(1, iDay + 1) = StartDate + iDay 'Change the row index 1 accordingly
Dim iCol As Integer
On Error GoTo Finish
For iCol = 1 To 16384
iDel = iDel + 1
If Not Cells(1, iCol + 1) - Cells(1, iCol) = 1 Then 'Change the row index 1 accordingly
Columns("A").Resize(, iDel).EntireColumn.Delete 'Change the Columns("A") accordingly