PritishS
Board Regular
- Joined
- Dec 29, 2015
- Messages
- 119
- Office Version
- 2007
- Platform
- Windows
Dear Sir/Madam,
I'm new to VBA. Trying to learn from internet and previously got best response here at Mr. Excel. I have got a wired kind of problem.
a. I have a worksheet named 'Template'. there I have a table template like below shown.
b. Here 'TOTAL QTY' column have a formula F4=E4*$C$2*$E$2
F5=E5*$C$2*$E$2
A B C D E F
[TABLE="width: 732, align: left"]
<tbody>[TR]
[TD]SWITCHBOARD NAME
[/TD]
[TD] PCC PANEL
[/TD]
[TD]BOARD QTY
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]FEEDER NAME
[/TD]
[TD] 630A MCCB Incomer
[/TD]
[TD]1
[/TD]
[TD]FQTY
[/TD]
[TD]2
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BOQDESCRIPTION
[/TD]
[TD]MAKE
[/TD]
[TD]CATALOG NUMBER
[/TD]
[TD]PRICE
[/TD]
[TD]QTY
[/TD]
[TD]TOTAL QTY
[/TD]
[/TR]
[TR]
[TD]630A 4P 55kA MCCB
[/TD]
[TD]AVK
[/TD]
[TD]3VL5763-1TN4
[/TD]
[TD]88390
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]Rotary drive
[/TD]
[TD]AVK
[/TD]
[TD]3VL9600-3HQ00
[/TD]
[TD]3530
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
</tbody>[/TABLE]
c. In another worksheet name 'BAT', I have a button called 'AddTemplate'. When I click this button this above shown entire template table get copied and pasted in 'BAT' worksheet.
d. My problem is when it first time get pasted, it's okay. but second time when I again click on 'AddTemplate' button, table template gets added after last used row. In this case TOTAL QTY absolute formula takes previous table's cell reference.
A B C D E F
[TABLE="width: 732, align: left"]
<tbody>[TR]
[TD]SWITCHBOARD NAME
[/TD]
[TD] PCC PANEL
[/TD]
[TD]BOARD QTY
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]FEEDER NAME
[/TD]
[TD] 630A MCCB Incomer
[/TD]
[TD]1
[/TD]
[TD]FQTY
[/TD]
[TD]2
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BOQDESCRIPTION
[/TD]
[TD]MAKE
[/TD]
[TD]CATALOG NUMBER
[/TD]
[TD]PRICE
[/TD]
[TD]QTY
[/TD]
[TD]TOTAL QTY
[/TD]
[/TR]
[TR]
[TD]630A 4P 55kA MCCB
[/TD]
[TD]AVK
[/TD]
[TD]3VL5763-1TN4
[/TD]
[TD]88390
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]Rotary drive
[/TD]
[TD]AVK
[/TD]
[TD]3VL9600-3HQ00
[/TD]
[TD]3530
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 732, align: left"]
<tbody>[TR]
[TD]SWITCHBOARD NAME
[/TD]
[TD] PCC PANEL
[/TD]
[TD]BOARD QTY
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]FEEDER NAME
[/TD]
[TD] 630A MCCB Incomer
[/TD]
[TD]1
[/TD]
[TD]FQTY
[/TD]
[TD]3
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BOQDESCRIPTION
[/TD]
[TD]MAKE
[/TD]
[TD]CATALOG NUMBER
[/TD]
[TD]PRICE
[/TD]
[TD]QTY
[/TD]
[TD]TOTAL QTY
[/TD]
[/TR]
[TR]
[TD]630A 4P 55kA MCCB
[/TD]
[TD]AVK
[/TD]
[TD]3VL5763-1TN4
[/TD]
[TD]88390
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]Rotary drive
[/TD]
[TD]AVK
[/TD]
[TD]3VL9600-3HQ00
[/TD]
[TD]3530
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
</tbody>[/TABLE]
For second Table template 'TOTAL QTY' should be F9=E9*$C$7*$E7$ & F10=E10*$C$7*$E7$
Instead of that the formula is F9=E9*$C$2*$E$2 & F10=E10*$C$2*$E$2
Is there any possibility to achieve this?
Temporarily I have made an arrangement. In 'Template' sheet I wrote the formula without $ like F4=E4*C2*E2
And when the formula have relative reference, I'm getting result as expected.
Please suggest me is there anyway even after copy and paste the template table from 'Template' sheet to 'BAT' sheet.
Help me please!
Thanks
PritishS
I'm new to VBA. Trying to learn from internet and previously got best response here at Mr. Excel. I have got a wired kind of problem.
a. I have a worksheet named 'Template'. there I have a table template like below shown.
b. Here 'TOTAL QTY' column have a formula F4=E4*$C$2*$E$2
F5=E5*$C$2*$E$2
A B C D E F
[TABLE="width: 732, align: left"]
<tbody>[TR]
[TD]SWITCHBOARD NAME
[/TD]
[TD] PCC PANEL
[/TD]
[TD]BOARD QTY
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]FEEDER NAME
[/TD]
[TD] 630A MCCB Incomer
[/TD]
[TD]1
[/TD]
[TD]FQTY
[/TD]
[TD]2
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BOQDESCRIPTION
[/TD]
[TD]MAKE
[/TD]
[TD]CATALOG NUMBER
[/TD]
[TD]PRICE
[/TD]
[TD]QTY
[/TD]
[TD]TOTAL QTY
[/TD]
[/TR]
[TR]
[TD]630A 4P 55kA MCCB
[/TD]
[TD]AVK
[/TD]
[TD]3VL5763-1TN4
[/TD]
[TD]88390
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]Rotary drive
[/TD]
[TD]AVK
[/TD]
[TD]3VL9600-3HQ00
[/TD]
[TD]3530
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
</tbody>[/TABLE]
c. In another worksheet name 'BAT', I have a button called 'AddTemplate'. When I click this button this above shown entire template table get copied and pasted in 'BAT' worksheet.
d. My problem is when it first time get pasted, it's okay. but second time when I again click on 'AddTemplate' button, table template gets added after last used row. In this case TOTAL QTY absolute formula takes previous table's cell reference.
A B C D E F
[TABLE="width: 732, align: left"]
<tbody>[TR]
[TD]SWITCHBOARD NAME
[/TD]
[TD] PCC PANEL
[/TD]
[TD]BOARD QTY
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]FEEDER NAME
[/TD]
[TD] 630A MCCB Incomer
[/TD]
[TD]1
[/TD]
[TD]FQTY
[/TD]
[TD]2
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BOQDESCRIPTION
[/TD]
[TD]MAKE
[/TD]
[TD]CATALOG NUMBER
[/TD]
[TD]PRICE
[/TD]
[TD]QTY
[/TD]
[TD]TOTAL QTY
[/TD]
[/TR]
[TR]
[TD]630A 4P 55kA MCCB
[/TD]
[TD]AVK
[/TD]
[TD]3VL5763-1TN4
[/TD]
[TD]88390
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]Rotary drive
[/TD]
[TD]AVK
[/TD]
[TD]3VL9600-3HQ00
[/TD]
[TD]3530
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 732, align: left"]
<tbody>[TR]
[TD]SWITCHBOARD NAME
[/TD]
[TD] PCC PANEL
[/TD]
[TD]BOARD QTY
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]FEEDER NAME
[/TD]
[TD] 630A MCCB Incomer
[/TD]
[TD]1
[/TD]
[TD]FQTY
[/TD]
[TD]3
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]BOQDESCRIPTION
[/TD]
[TD]MAKE
[/TD]
[TD]CATALOG NUMBER
[/TD]
[TD]PRICE
[/TD]
[TD]QTY
[/TD]
[TD]TOTAL QTY
[/TD]
[/TR]
[TR]
[TD]630A 4P 55kA MCCB
[/TD]
[TD]AVK
[/TD]
[TD]3VL5763-1TN4
[/TD]
[TD]88390
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
[TR]
[TD]Rotary drive
[/TD]
[TD]AVK
[/TD]
[TD]3VL9600-3HQ00
[/TD]
[TD]3530
[/TD]
[TD]1
[/TD]
[TD]2
[/TD]
[/TR]
</tbody>[/TABLE]
For second Table template 'TOTAL QTY' should be F9=E9*$C$7*$E7$ & F10=E10*$C$7*$E7$
Instead of that the formula is F9=E9*$C$2*$E$2 & F10=E10*$C$2*$E$2
Is there any possibility to achieve this?
Temporarily I have made an arrangement. In 'Template' sheet I wrote the formula without $ like F4=E4*C2*E2
And when the formula have relative reference, I'm getting result as expected.
Please suggest me is there anyway even after copy and paste the template table from 'Template' sheet to 'BAT' sheet.
Help me please!
Thanks
PritishS