まずは、初心者には初心者です。私は複数のブックとして作成して保存するテンプレートブックから、異なるタイプのセル(つまり、文字列、倍精度)を参照する必要があります。私はマスターファイルに転送する値や文字列を取得する方法を考え出したが、ワークブックの1つを開き、値を変更してマスターファイルも変更できるようにしたい。また、マスタブックは他のブックとは別の場所に保存されます。どんな助けもありがとう。さまざまなタイプのセル(つまり、文字列、倍精度)を参照する - 複数のワークブック
おかげ
Sub HyperLink()
'This macro creates a new excel workbook based on the selected part number of the master file.
'It also fills in three cells in the newly created excel file based on the master.
'Certain cells in the newly created workbook are referenced back to the master
'Finally the part number in the master excel is hyperlinked to the newly created excel
Dim PartNumber As String
Dim EAU As Integer
Dim CurrentMaterial As Double
Dim SimForging As String
Dim EstForging As String
Dim ProcessSavings As String
ColumnLocation = ActiveCell.Column
CellLocation = ActiveCell.Address
PartNumber = Cells(ActiveCell.Row, ActiveCell.Column) 'Defines the part number for the active cell
EAU = ActiveCell.Offset(0, 1).Value 'Defines the EAU for the selected part number (column C)
CurrentMaterial = ActiveCell.Offset(0, 2).Value 'Defines the Mat. Cost for the selected part number (column D)
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
If IsNull(PartNumber) = False Then
Workbooks.Add
FilePath = "C:\Documents and Settings\Brandon's\Desktop\Forging Justification\" & PartNumber & ".xlsx"
Workbooks.Open Filename:="C:\Documents and Settings\Brandon's\Desktop\Forging Justification\Template.xls"
Range("A2").Select
ActiveWorkbook.SaveAs Filename:=FilePath, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Range("A2").Select
ActiveCell.Value = PartNumber
ActiveCell.Offset(4, 0).Value = EAU
ActiveCell.Offset(0, 3).Value = CCur(CurrentMaterial)
'I dont know what to use here?????????????????????
SimForging = Range("A8").FormulaR1C1
ProcessSavings = Range("C11").FormulaR1C1
EstForging = Range("F2").FormulaR1C1
ActiveWorkbook.Save
ActiveWindow.Close
ActiveWindow.Close
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="Pricing\" & PartNumber & ".xlsx", TextToDisplay:=PartNumber
'Again I don't know what to do here in order to make it dynamic????????????
'I want to be able to change the EstForging in PartNumber.xlsx and have it update the master file
ActiveCell.Offset(0, 4) = EstForging
ActiveCell.Offset(0, 5) = SimForging
ActiveCell.Offset(0, 7) = ProcessSavings
ActiveWorkbook.Save
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = CalcMode
End With
End If
End Sub
Siddarth、
応答のおかげで、それは次のように動作するはずです。
セル(製品型番すなわち。1234)私はのためのマクロを実行して開始したいを選択してマクロ
1)製品型番、EAUおよびCurrentMaterial
製品型番=細胞(ActiveCell.Row、ActiveCell.Columnの定義) EAU = ActiveCell.Offset(0、1).Valueの
CurrentMaterial = ActiveCell.Offset(0,2).Valueの
2)私が作成したテンプレートを開きます。 Workbooks.Openファイル名:= "X:\新しいパーツ - ミラー、クラム\鍛造の正当化の\ Template.xls"。
3)新しいファイル(つまりとしてTemplate.xlsを保存1234.xlsx)
」 C: "&製品型番&" の.xlsx \ \ DocumentsとSettings \ブランドンの\デスクトップ\鍛造正当化A2 ")」
4)1234.xlsx
範囲(製品型番に、EAUおよびCurrentMaterialを配置" を選択します。
ActiveCell.Value = PartNumber
ActiveCell.Offset(3、0).Value = EAU
ActiveCell.Offset(0,3).Valueの= CCur(CurrentMaterial)
5) SimForging = ActiveCell.Offset(、)
EstForging = ActiveCellの1234.xlsx
でSimForging、EstForgingとProcessSavingsを定義します。オフセット(、)
ProcessSavings = ActiveCell.Offset(、)
6)1234.xlsxを保存して閉じます。再びアクティブ・マスター・ファイルに
7)、製品型番
ActiveCell.Offset(、)= SimForging
ActiveCell.Offset(、)= EstForging
のActiveCellと同じ行にSimforging、EstForgingとProcessSavingsを置きます。 (、)オフセット= ProcessSavings
8))1234.xlsx(私が作成したファイルへの製品型番セルにハイパーリンクを追加
ActiveSheet.Hyperlinks.Addアンカー:=の選択、住所:= "価格\" & PartNumber & ".xlsx"、_ TextToDisplay:= PartNumber
9)マスタブックを保存し、マクロを停止します。
次に、ハイパーリンクをクリックして1234.xlsxを開きたいと思っています。
1234.xlsx内のProcessSavingsを変更して保存して閉じます。
マスターブックの変更を確認できます。
今私は1234.xlsxから値を持ち出すことができましたが、私はそれらを変更するとマスターファイルで更新されませんEstForgingとProcessSavingsはdouble型ですが、 SimForgingは文字列です。
ポイント5を明示してください。どこから値を取得しようとしていますか? –
新しく作成したExcel(つまり1234.xlsx)のセルをマスターブックに戻して参照しようとしています。だから、マスターブックの中で、私はこのActiveCell.Offset(0,23)= "= 'C:\ Documents and Settings \ Brandonの\ Desktop \ Forging Justification \ [1234.xlsx] Sheet1'!$ C $ 11" – user1251120
その式をSimForgingに保存しようとしていますか? –