11.20.2556

Excel : Replace cells with a Header of column

Code for Replace cells with a Header of column. 

- Design start column and end column that want to replace.
- Copy cell(Header)
- Select range by F5 Go to spacial>Constants>all
  (Select cells that not blank)
- Paste value(Header)
- Loop(Do While)
------------------------------------------------------------------------------------------------------------
Sub ReplaceDataWithHeader()
Dim strCol As String
Dim lngCol As Long
lngCol = 240
 Do While lngCol < 248
    Cells(6, lngCol).Select
    Selection.Copy
    ActiveWindow.SmallScroll Down:=-18
    Range(Cells(27, lngCol), Cells(8096, lngCol)).Select
    Selection.SpecialCells(xlCellTypeConstants, 23).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    lngCol = lngCol + 1
 Loop
End Sub
------------------------------------------------------------------------------------------------------------

ไม่มีความคิดเห็น:

แสดงความคิดเห็น