Need VBA macro code to fill the data into Salary Slip template excel sheet from input file

Rampage598

New Member
Joined
Mar 11, 2022
Messages
23
Office Version
  1. 365
Platform
  1. Windows
1651038039513.png

This is my Input File.........
and this is the template file
1651038083945.png

all the data will get fill into this template file....
But main scenario is ...
1651038178861.png

For first Employee there is no data in HRA column so then it will remove HRA from Salary slip template file
1651039225002.png

For second employee there is no data in BASIC column then it will remove BASIC from template file
1651039379851.png

can anyone give me macro code for this?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
assuming your looping through the input file rows using a variable named "i" and with no clue of sheet names etc...

VBA Code:
If ThisWorkbook.Sheets("Input File").Cells(1, 9) = "" Then 'HRA cell is blank
    ThisWorkbook.Sheets("Template File").Range("B9") = "" 'clear "Basic" from cell
Else
    ThisWorkbook.Sheets("Template File").Range("B9") = "Basic" 'if not then input "Basic" into cell.
End If

A simple if statement for each criteria should suffice. The above is for the 1st scenario.
 
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,166
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top