excel_VB宏脚本_批量生成点餐宝接受的格式

Attribute VB_Name = "模块1"

'作者:landv
'开发时间:2015年12月28日18:09:34
'主要功能,为东风路小厨生成农行点餐宝所支持批量导入的格式。复制H行到TXT文本修改成UTF_8格式即可。

Function pinyin(p As String) As String
 
i = Asc(p)
 
Select Case i
 
Case -20319 To -20284: pinyin = "A"
 
Case -20283 To -19776: pinyin = "B"
 
Case -19775 To -19219: pinyin = "C"
 
Case -19218 To -18711: pinyin = "D"
 
Case -18710 To -18527: pinyin = "E"
 
Case -18526 To -18240: pinyin = "F"
 
Case -18239 To -17923: pinyin = "G"
 
Case -17922 To -17418: pinyin = "H"
 
Case -17417 To -16475: pinyin = "J"
 
Case -16474 To -16213: pinyin = "K"
 
Case -16212 To -15641: pinyin = "L"
 
Case -15640 To -15166: pinyin = "M"
 
Case -15165 To -14923: pinyin = "N"
 
Case -14922 To -14915: pinyin = "O"
 
Case -14914 To -14631: pinyin = "P"
 
Case -14630 To -14150: pinyin = "Q"
 
Case -14149 To -14091: pinyin = "R"
 
Case -14090 To -13319: pinyin = "S"
 
Case -13318 To -12839: pinyin = "T"
 
Case -12838 To -12557: pinyin = "W"
 
Case -12556 To -11848: pinyin = "X"
 
Case -11847 To -11056: pinyin = "Y"
 
Case -11055 To -2050: pinyin = "Z"
 
Case Else: pinyin = p
 
End Select
 
End Function
 
Function getpy(str)
 
For i = 1 To Len(str)
 
getpy = getpy & pinyin(Mid(str, i, 1))
 
Next i
 
End Function


Sub landv()

'删除无用
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
  Columns("E:H").Select
    Selection.Delete Shift:=xlToLeft
    Columns("G:K").Select
    Selection.Delete Shift:=xlToLeft
'剪切类别到第一行
 Columns("E:F").Select
    Selection.Cut
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight
'删除格式
Cells.Select
    Selection.ClearFormats
'删除B2
 Columns("B:B").Select
    Selection.Delete Shift:=xlToLeft

'批量替换成类别编码,没有用循环,直接暴力一点吧。
 Columns("A:B").Select
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="白酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="本地", Replacement:="2", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="茶水", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="果盘", Replacement:="1", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="果汁", Replacement:="9", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="红酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="花雕酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅锅底", Replacement:="10", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅肉类", Replacement:="11", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅蔬菜", Replacement:="12", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅小料", Replacement:="10", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="凉菜", Replacement:="1", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="面点", Replacement:="8", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="啤酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="破损", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="商品", Replacement:="4", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="四大罩", Replacement:="7", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="香烟", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="烤鱼", Replacement:="5", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="伴侣", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="热菜", Replacement:="2", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="烧烤", Replacement:="5", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="铁板", Replacement:="6", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="蒸炖", Replacement:="6", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="雅间费", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="饮料", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

'品相名称转换成拼音
Columns("D:D").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "=getpy(RC[-1])"
    Range("D1").Select
    Selection.AutoFill Destination:=Range("D1:D395")
    Range("D1:D395").Select
'插入管道符
Range("G1").Select
    ActiveCell.FormulaR1C1 = "|"
    Range("G1").Select
    Selection.AutoFill Destination:=Range("G1:G395")
    Range("G1:G395").Select
'生成最终格式
 Range("H1").Select
    ActiveCell.FormulaR1C1 = _
        "=RC[-7]&RC[-1]&RC[-6]&RC[-1]&RC[-5]&RC[-1]&RC[-4]&RC[-1]&RC[-3]&RC[-1]&RC[-2]"
    Range("H1").Select
    Selection.AutoFill Destination:=Range("H1:H395")
    Range("H1:H395").Select


End Sub

 处理几个小毛病,对其他人适用性不是很大,作为参考还是可以的嘛

Attribute VB_Name = "自动处理"
'版本:1.0.2
'作者:landv
'开发时间:2015年12月28日18:09:34
'主要功能,为东风路小厨生成农行点餐宝所支持批量导入的格式。复制H行到TXT文本修改成UTF_8格式即可。

Function pinyin(p As String) As String
 
i = Asc(p)
 
Select Case i
 
Case -20319 To -20284: pinyin = "A"
 
Case -20283 To -19776: pinyin = "B"
 
Case -19775 To -19219: pinyin = "C"
 
Case -19218 To -18711: pinyin = "D"
 
Case -18710 To -18527: pinyin = "E"
 
Case -18526 To -18240: pinyin = "F"
 
Case -18239 To -17923: pinyin = "G"
 
Case -17922 To -17418: pinyin = "H"
 
Case -17417 To -16475: pinyin = "J"
 
Case -16474 To -16213: pinyin = "K"
 
Case -16212 To -15641: pinyin = "L"
 
Case -15640 To -15166: pinyin = "M"
 
Case -15165 To -14923: pinyin = "N"
 
Case -14922 To -14915: pinyin = "O"
 
Case -14914 To -14631: pinyin = "P"
 
Case -14630 To -14150: pinyin = "Q"
 
Case -14149 To -14091: pinyin = "R"
 
Case -14090 To -13319: pinyin = "S"
 
Case -13318 To -12839: pinyin = "T"
 
Case -12838 To -12557: pinyin = "W"
 
Case -12556 To -11848: pinyin = "X"
 
Case -11847 To -11056: pinyin = "Y"
 
Case -11055 To -2050: pinyin = "Z"
 
Case Else: pinyin = p
 
End Select
 
End Function
 
Function getpy(str)
 
For i = 1 To Len(str)
 
getpy = getpy & pinyin(Mid(str, i, 1))
 
Next i
 
End Function


Sub landv()
'变量,文件最后一行
Dim a_hang
a_hang = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row - 2


'删除无用
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
  Columns("E:H").Select
    Selection.Delete Shift:=xlToLeft
    Columns("G:K").Select
    Selection.Delete Shift:=xlToLeft
'剪切类别到第一行
 Columns("E:F").Select
    Selection.Cut
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight
'删除格式
Cells.Select
    Selection.ClearFormats
'删除B2
 Columns("B:B").Select
    Selection.Delete Shift:=xlToLeft

'批量替换成类别编码,没有用循环,直接暴力一点吧。
 Columns("A:B").Select
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="白酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="本地", Replacement:="2", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="茶水", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="果盘", Replacement:="1", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="果汁", Replacement:="9", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="红酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="花雕酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅锅底", Replacement:="10", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅肉类", Replacement:="11", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅蔬菜", Replacement:="12", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅小料", Replacement:="10", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="凉菜", Replacement:="13", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="面点", Replacement:="8", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="啤酒", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="破损", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="商品", Replacement:="4", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="四大罩", Replacement:="7", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="香烟", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="烤鱼", Replacement:="5", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="伴侣", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
         ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="热菜", Replacement:="2", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="烧烤", Replacement:="5", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="铁板", Replacement:="6", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="蒸炖", Replacement:="6", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="雅间费", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="饮料", Replacement:="3", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

'品相名称转换成拼音
Columns("D:D").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "=getpy(RC[-1])"
    Range("D1").Select
    Selection.AutoFill Destination:=Range("D1:D" & a_hang)
    Range("D1:D" & a_hang).Select
'插入管道符
Range("G1").Select
    ActiveCell.FormulaR1C1 = "|"
    Range("G1").Select
    Selection.AutoFill Destination:=Range("G1:G" & a_hang)
    Range("G1:G" & a_hang).Select
'生成最终格式
 Range("H1").Select
    ActiveCell.FormulaR1C1 = _
        "=RC[-7]&RC[-1]&RC[-6]&RC[-1]&RC[-5]&RC[-1]&RC[-4]&RC[-1]&RC[-3]&RC[-1]&RC[-2]"
    Range("H1").Select
    Selection.AutoFill Destination:=Range("H1:H" & a_hang)
    Range("H1:H" & a_hang).Select

MsgBox "搞定了,该怎么感谢我呢!"

End Sub

2015年12月31日15:20:30

版本:1.0.3

定义了转换类别的变量,这样可以方便阅读,也方便了修改。

仍然采用暴力解决,准备在1.0.4版本定义函数并使用循环,从而进行压缩代码。

Attribute VB_Name = "自动处理"
'版本:1.0.3
'作者:landv
'开发时间:2015年12月28日18:09:34
'主要功能,为东风路小厨生成农行点餐宝所支持批量导入的格式。复制H行到TXT文本修改成UTF_8格式即可。

Function pinyin(p As String) As String
 
i = Asc(p)
 
Select Case i
 
Case -20319 To -20284: pinyin = "A"
 
Case -20283 To -19776: pinyin = "B"
 
Case -19775 To -19219: pinyin = "C"
 
Case -19218 To -18711: pinyin = "D"
 
Case -18710 To -18527: pinyin = "E"
 
Case -18526 To -18240: pinyin = "F"
 
Case -18239 To -17923: pinyin = "G"
 
Case -17922 To -17418: pinyin = "H"
 
Case -17417 To -16475: pinyin = "J"
 
Case -16474 To -16213: pinyin = "K"
 
Case -16212 To -15641: pinyin = "L"
 
Case -15640 To -15166: pinyin = "M"
 
Case -15165 To -14923: pinyin = "N"
 
Case -14922 To -14915: pinyin = "O"
 
Case -14914 To -14631: pinyin = "P"
 
Case -14630 To -14150: pinyin = "Q"
 
Case -14149 To -14091: pinyin = "R"
 
Case -14090 To -13319: pinyin = "S"
 
Case -13318 To -12839: pinyin = "T"
 
Case -12838 To -12557: pinyin = "W"
 
Case -12556 To -11848: pinyin = "X"
 
Case -11847 To -11056: pinyin = "Y"
 
Case -11055 To -2050: pinyin = "Z"
 
Case Else: pinyin = p
 
End Select
 
End Function
 
Function getpy(str)
 
For i = 1 To Len(str)
 
getpy = getpy & pinyin(Mid(str, i, 1))
 
Next i
 
End Function


Sub landv()
'变量,文件最后一行
Dim a_hang
a_hang = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row - 2
'定义转换类别变量
dim 小厨热菜,小厨凉菜,小厨蒸炖,小厨烤鱼,小厨烤鱼伴侣,小厨烧烤,小厨面点,四大罩,会馆热菜,会馆凉菜,会馆海鲜,会馆高档类,果盘,饮料,吧台,火锅锅底,火锅肉类,火锅蔬菜,火锅小料,包桌套餐,面点
小厨热菜 =1
小厨凉菜 =2
小厨蒸炖 =3
小厨烤鱼 =4
小厨烤鱼伴侣 =5
小厨烧烤 =6
小厨面点 =7
四大罩 =8
会馆热菜 =9
会馆凉菜 =10
会馆海鲜 =11
会馆高档类 =12
果盘 =13
饮料 =14
吧台 =15
火锅锅底= 16
火锅肉类=17
火锅蔬菜=18
火锅小料=19
包桌套餐=20
面点=21
'删除无用
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
  Columns("E:H").Select
    Selection.Delete Shift:=xlToLeft
    Columns("G:K").Select
    Selection.Delete Shift:=xlToLeft
'剪切类别到第一行
 Columns("E:F").Select
    Selection.Cut
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight
'删除格式
Cells.Select
    Selection.ClearFormats
'删除B2
 Columns("B:B").Select
    Selection.Delete Shift:=xlToLeft

'批量替换成类别编码,没有用循环,直接暴力一点吧。
 Columns("A:B").Select
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨烤鱼", Replacement:=(""&小厨烤鱼), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨烤鱼伴侣", Replacement:=(""&小厨烤鱼伴侣), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨凉菜", Replacement:=(""&小厨凉菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨面点", Replacement:=(""&小厨面点), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨热菜", Replacement:=(""&小厨热菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨烧烤", Replacement:=(""&小厨烧烤), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="小厨蒸炖", Replacement:=(""&小厨蒸炖), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="雅间费", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="洋酒", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="饮料", Replacement:=(""&饮料), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="月饼", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="白酒", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="包桌套餐", Replacement:=(""&包桌套餐), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="本地", Replacement:=(""&会馆热菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="茶水", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="川菜", Replacement:=(""&会馆热菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="高档类", Replacement:=(""&会馆高档类), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="果盘", Replacement:=(""&果盘), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="果汁", Replacement:=(""&饮料), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="海鲜", Replacement:=(""&会馆海鲜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="红酒", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="红酒", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="花雕酒", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅锅底", Replacement:=(""&火锅锅底), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅肉类", Replacement:=(""&火锅肉类), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅蔬菜", Replacement:=(""&火锅蔬菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="火锅小料", Replacement:=(""&火锅小料), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="凉菜", Replacement:=(""&会馆凉菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="面点", Replacement:=(""&会馆面点), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="啤酒", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="破损", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
        ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="商品", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="四大罩", Replacement:=(""&四大罩), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="外包菜", Replacement:=(""&会馆热菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="香烟", Replacement:=(""&吧台), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
ActiveCell.Columns("A:B").EntireColumn.Select
    Selection.Replace What:="湘菜", Replacement:=(""&会馆热菜), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False




'品相名称转换成拼音
Columns("D:D").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "=getpy(RC[-1])"
    Range("D1").Select
    Selection.AutoFill Destination:=Range("D1:D" & a_hang)
    Range("D1:D" & a_hang).Select
'插入管道符
Range("G1").Select
    ActiveCell.FormulaR1C1 = "|"
    Range("G1").Select
    Selection.AutoFill Destination:=Range("G1:G" & a_hang)
    Range("G1:G" & a_hang).Select
'生成最终格式
 Range("H1").Select
    ActiveCell.FormulaR1C1 = _
        "=RC[-7]&RC[-1]&RC[-6]&RC[-1]&RC[-5]&RC[-1]&RC[-4]&RC[-1]&RC[-3]&RC[-1]&RC[-2]"
    Range("H1").Select
    Selection.AutoFill Destination:=Range("H1:H" & a_hang)
    Range("H1:H" & a_hang).Select

MsgBox "搞定了,该怎么感谢我呢!"

End Sub

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏函数式编程语言及工具

Scalaz(45)- concurrency :Task-函数式多线程编程核心配件

    我们在上一节讨论了scalaz Future,我们说它是一个不完善的类型,最起码没有完整的异常处理机制,只能用在构建类库之类的内部环境。如果scalaz...

2846
来自专栏技术博客

编写高质量代码改善C#程序的157个建议[为类型输出格式化字符串、实现浅拷贝和深拷贝、用dynamic来优化反射]

  本文已更新至http://www.cnblogs.com/aehyok/p/3624579.html 。本文主要学习记录以下内容:

903
来自专栏大内老A

我的WCF之旅(4):WCF中的序列化[下篇]

XMLSerializer 提到XMLSerializer,我想绝大多数人都知道这是asmx采用的Serializer。首先我们还是来看一个例子,通过比较Ma...

20910
来自专栏跟着阿笨一起玩NET

[C#] 常用工具类——直接在浏览器输出数据

1692
来自专栏葡萄城控件技术团队

最全数据结构详述: List VS IEnumerable VS IQueryable VS ICollection VS IDictionary

本文对常用的数据结构详述:Array, ArrayList,List,IList,ICollection, Stack, Queue, HashTable, D...

2688
来自专栏.NET开发者社区

.NET[C#]中实现实体对象深拷贝(克隆/复制)的几种方法

.NET[C#]中实现实体对象深拷贝(克隆/复制)的几种方法,总有一种适合你。 方式一 使用二进制流 using System; using System.IO...

2266
来自专栏菩提树下的杨过

ruby学习笔记(3)--语法层面的先见之明

看了几天ruby,发现c#中很多一直被称道的语法特性,ruby早在几年前就有了:  1.c#中的params关键字 class Program ...

2145
来自专栏跟着阿笨一起玩NET

C#如何把List of Object转换成List of T具体类型

上周码程序的时候碰到个问题,因为设计上的约束,一个方法接受的参数只能为List<object>类型,然而该方法需要处理的真实数据则是确定的List<Curren...

2311
来自专栏angularejs学习篇

c#中jeson字符串和OBJECT对象的相互转换

说明:首先,当然是项目是3.5+的;必须添加引用:System.Runtime.Serialization 和 System.ServiceModel

3412
来自专栏菩提树下的杨过

Linq之ToDictionary<TSource, TKey, TElement>的写法

以前一直用 var query = xxx.Select(c=>new {c.X,c.Y}); 来取表中的某二列字段,今天有个应用需要转成Dictionary<...

21610

扫码关注云+社区