Excel 读取一张包含值列表的工作表,将其拉入另一张计算器工作表,然后将计算出的值复制回第一张工作表

Excel 读取一张包含值列表的工作表,将其拉入另一张计算器工作表,然后将计算出的值复制回第一张工作表,excel,vba,Excel,Vba,我想把C度(带压力补偿)转换成PPMv 我有两张床单。第一张表是包含原始数据的表。我有另一个计算器表(我从网上得到的),它是把C度转换成PPMv。我想将两种类型的数据(C度和压力)复制到计算器,然后将计算值复制回第一张图纸 代码: 我相信这是您的代码的更好版本: Sub CaculatePPM() Dim Iteration As Integer 'Set iteration to the first row to be processed Iteration

我想把C度(带压力补偿)转换成PPMv

我有两张床单。第一张表是包含原始数据的表。我有另一个计算器表(我从网上得到的),它是把C度转换成PPMv。我想将两种类型的数据(C度和压力)复制到计算器,然后将计算值复制回第一张图纸

代码:


我相信这是您的代码的更好版本:

Sub CaculatePPM()
    Dim Iteration As Integer

    'Set iteration to the first row to be processed    
    Iteration = 7

    'Loop while there is data to be processed
    Do Until Sheets("DewPoint").Cells(Iteration, "D").Value = ""
        'Copy data to Calculator sheet
        Sheets("Calculator").Range("D14").Value = Sheets("DewPoint").Cells(Iteration, "D").Value
        Sheets("Calculator").Range("D16").Value = Sheets("DewPoint").Cells(Iteration, "F").Value

        'This next statement is probably not necessary, but I have included
        'it just in case Excel is set to Manual Calculation
        Sheets("Calculator").Calculate

        'Copy results back to DewPoint sheet
        Sheets("DewPoint").Cells(Iteration, "G").Value = Sheets("Calculator").Range("B19").Value

        'This originally said "Iteration = Iteration - 1"
        'Change it back if you are trying to process rows starting from 7 and working UPWARDS
        Iteration = Iteration + 1
    Loop

End Sub
Sub CaculatePPM()
    Dim Iteration As Integer

    'Set iteration to the first row to be processed    
    Iteration = 7

    'Loop while there is data to be processed
    Do Until Sheets("DewPoint").Cells(Iteration, "D").Value = ""
        'Copy data to Calculator sheet
        Sheets("Calculator").Range("D14").Value = Sheets("DewPoint").Cells(Iteration, "D").Value
        Sheets("Calculator").Range("D16").Value = Sheets("DewPoint").Cells(Iteration, "F").Value

        'This next statement is probably not necessary, but I have included
        'it just in case Excel is set to Manual Calculation
        Sheets("Calculator").Calculate

        'Copy results back to DewPoint sheet
        Sheets("DewPoint").Cells(Iteration, "G").Value = Sheets("Calculator").Range("B19").Value

        'This originally said "Iteration = Iteration - 1"
        'Change it back if you are trying to process rows starting from 7 and working UPWARDS
        Iteration = Iteration + 1
    Loop

End Sub