Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2024|回复: 2

[已解决]信息表保存为图片,未填写提交时进行提醒

[复制链接]
发表于 2021-8-27 10:03 | 显示全部楼层 |阅读模式


1表格信息随编号的变化,信息也开始变,自动将没个信息表保存为图片,图片以名字加身份证号码命名;
2未填写提交时进行提醒,那个未填,或者单元格变颜色.

最佳答案
2021-8-31 12:55
在表格文件夹下面创建  名为“图片” 文件夹,

Sub 提交1()
Application.ScreenUpdating = False
Dim n%, m%, x%, y%, k%
On Error GoTo 100
    If Sheets("数据库").[A:A].Find([j3]) = [j3] Then
        MsgBox "此单已经保存过了!"
    Else
100:
        rr = Array([c4], [j4], [c5], [j5], [c6], [j6], [b7], [d7], [f7], [h7], [j7], [b8], [d8], [f8], [h8], [j8], [b10], [f10], [b11])
        ss = Array([b4], [i4], [b5], [i5], [b6], [i6], [a7], [c7], [e7], [g7], [i7], [a8], [c8], [e8], [g8], [i8], [a10], [e10], [a11])
        For i = 0 To UBound(rr)
            If Trim(rr(i)) = "" Then
                If a = "" Then
                   a = ss(i) & ":" & Replace(rr(i).Address, "$", "")
                    Range(Replace(rr(i).Address, "$", "")).Interior.Color = RGB(255, 153, 204)
                Else
                    a = a & Chr(10) & ss(i) & ":" & Replace(rr(i).Address, "$", "")
                    Range(Replace(rr(i).Address, "$", "")).Interior.Color = RGB(255, 153, 204)
                End If
            End If
        Next i
        If a <> "" Then
            MsgBox "以下单元格为空:" & Chr(10) & " " & Chr(10) & a & Chr(10) & " " & Chr(10) & "不能提交" & Chr(10) & Chr(10) & "请修改后再提交"
            Exit Sub
        End If
        
        m = Sheets("数据库").[A65536].End(xlUp).Row + 1
        With Sheets("数据库")
            .Cells(m, "A").Value = [j3] '编号
            .Cells(m, "B").Value = [j4] '开单日期
            .Cells(m, "C").Value = [c4] '客户
            .Cells(m, "D").Value = [c5] '品名
            .Cells(m, "E").Value = [c6] '料号
            .Cells(m, "F").Value = [j6] '成品规格
            .Cells(m, "G").Value = [j5] '生产数量
            .Cells(m, "H").Value = [b9] '封样单号
            .Cells(m, "I").Value = [E9] '刀模编号
            .Cells(m, "J").Value = [i10] '拼版数量
            .Cells(m, "K").Value = [b7] '材料1
            .Cells(m, "L").Value = [h7] '规格1
            .Cells(m, "M").Value = [f7] '供应商1
            .Cells(m, "N").Value = [j7] '材料数量
            .Cells(m, "O").Value = [b8] '材料2
            .Cells(m, "P").Value = [h8] '规格2
            .Cells(m, "Q").Value = [f8] '供应商2
            .Cells(m, "R").Value = [j8] '材料数量2
            .Cells(m, "S").Value = [H9] '加工车次
            .Cells(m, "T").Value = [b10] '包装方式
            .Cells(m, "U") = [f10] '包装数量
            .Cells(m, "V").Value = [J9] '交期
            .Cells(m, "W").Value = [b11] '物流方式
        End With
        MsgBox "提交成功!"
    End If
   
Range("c4, j4, c5, j5, c6, j6, b7, d7, f7, h7, j7, b8, d8, f8, h8, j8, b10, f10, b11").Interior.Pattern = xlNone    '单元格背景--无颜色

Range("A2:K11").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Paste
     Set Newshape = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
     With ActiveSheet.ChartObjects.Add(1, 1, 1, 1)
         .Width = Newshape.Width
         .Height = Newshape.Height
          Newshape.Copy
         .Select
         .Chart.Paste
         .Chart.Export ActiveWorkbook.Path & "\图片\" & Cells(4, 3) & " " & Cells(5, 3) & ".JPG"
         .Delete
     End With
     Newshape.Delete
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub

生产开单系统.zip

16.11 KB, 下载次数: 7

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
 楼主| 发表于 2021-8-27 12:29 | 显示全部楼层
回复

使用道具 举报

发表于 2021-8-31 12:55 | 显示全部楼层    本楼为最佳答案   
在表格文件夹下面创建  名为“图片” 文件夹,

Sub 提交1()
Application.ScreenUpdating = False
Dim n%, m%, x%, y%, k%
On Error GoTo 100
    If Sheets("数据库").[A:A].Find([j3]) = [j3] Then
        MsgBox "此单已经保存过了!"
    Else
100:
        rr = Array([c4], [j4], [c5], [j5], [c6], [j6], [b7], [d7], [f7], [h7], [j7], [b8], [d8], [f8], [h8], [j8], [b10], [f10], [b11])
        ss = Array([b4], [i4], [b5], [i5], [b6], [i6], [a7], [c7], [e7], [g7], [i7], [a8], [c8], [e8], [g8], [i8], [a10], [e10], [a11])
        For i = 0 To UBound(rr)
            If Trim(rr(i)) = "" Then
                If a = "" Then
                   a = ss(i) & ":" & Replace(rr(i).Address, "$", "")
                    Range(Replace(rr(i).Address, "$", "")).Interior.Color = RGB(255, 153, 204)
                Else
                    a = a & Chr(10) & ss(i) & ":" & Replace(rr(i).Address, "$", "")
                    Range(Replace(rr(i).Address, "$", "")).Interior.Color = RGB(255, 153, 204)
                End If
            End If
        Next i
        If a <> "" Then
            MsgBox "以下单元格为空:" & Chr(10) & " " & Chr(10) & a & Chr(10) & " " & Chr(10) & "不能提交" & Chr(10) & Chr(10) & "请修改后再提交"
            Exit Sub
        End If
        
        m = Sheets("数据库").[A65536].End(xlUp).Row + 1
        With Sheets("数据库")
            .Cells(m, "A").Value = [j3] '编号
            .Cells(m, "B").Value = [j4] '开单日期
            .Cells(m, "C").Value = [c4] '客户
            .Cells(m, "D").Value = [c5] '品名
            .Cells(m, "E").Value = [c6] '料号
            .Cells(m, "F").Value = [j6] '成品规格
            .Cells(m, "G").Value = [j5] '生产数量
            .Cells(m, "H").Value = [b9] '封样单号
            .Cells(m, "I").Value = [E9] '刀模编号
            .Cells(m, "J").Value = [i10] '拼版数量
            .Cells(m, "K").Value = [b7] '材料1
            .Cells(m, "L").Value = [h7] '规格1
            .Cells(m, "M").Value = [f7] '供应商1
            .Cells(m, "N").Value = [j7] '材料数量
            .Cells(m, "O").Value = [b8] '材料2
            .Cells(m, "P").Value = [h8] '规格2
            .Cells(m, "Q").Value = [f8] '供应商2
            .Cells(m, "R").Value = [j8] '材料数量2
            .Cells(m, "S").Value = [H9] '加工车次
            .Cells(m, "T").Value = [b10] '包装方式
            .Cells(m, "U") = [f10] '包装数量
            .Cells(m, "V").Value = [J9] '交期
            .Cells(m, "W").Value = [b11] '物流方式
        End With
        MsgBox "提交成功!"
    End If
   
Range("c4, j4, c5, j5, c6, j6, b7, d7, f7, h7, j7, b8, d8, f8, h8, j8, b10, f10, b11").Interior.Pattern = xlNone    '单元格背景--无颜色

Range("A2:K11").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ActiveSheet.Paste
     Set Newshape = ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
     With ActiveSheet.ChartObjects.Add(1, 1, 1, 1)
         .Width = Newshape.Width
         .Height = Newshape.Height
          Newshape.Copy
         .Select
         .Chart.Paste
         .Chart.Export ActiveWorkbook.Path & "\图片\" & Cells(4, 3) & " " & Cells(5, 3) & ".JPG"
         .Delete
     End With
     Newshape.Delete
ActiveWorkbook.Save
Application.ScreenUpdating = True
End Sub
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-2 18:21 , Processed in 0.323306 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表