PDA

View Full Version : populate default values in cell of a csv file



dhivya.enjoy
10-22-2013, 12:16 PM
Hi Team,

Below data is from a csv file which I am generating using a macro. Data will be entered in an excel sheet and on running the macro it will generate the csv file. But the last column IS_ACTIVE is not there in my excel sheet. Its an additional column which I am adding to csv alone separately. Now I want to populate the value of the column IS_ACTIVE as YES .Its a default value for all the rows in that column. Kindly let me know the code in vba using which I can achieve the same.


RATE_OFFERING
S.No Rate Name CARGO TYPE PORT TRANSPORT MODE IS_ACTIVE
SAMPLE 1 RR_TEST4 CONVENTIONAL AIRPORT AIR
SAMPLE 2 RR_TEST5 CONVENTIONAL AIRPORT AIR
SAMPLE 3 RR_TEST6 CONVENTIONAL AIRPORT AIR
SAMPLE 4 RR_TEST7 CONVENTIONAL AIRPORT AIR
SAMPLE 5 RR_TEST8 CONVENTIONAL AIRPORT AIR
SAMPLE 6 RR_TEST9 CONVENTIONAL AIRPORT AIR
SAMPLE 7 RR_TEST10 CONVENTIONAL AIRPORT AIR
SAMPLE 8 RR_TEST11 CONVENTIONAL AIRPORT AIR

alansidman
10-22-2013, 05:31 PM
Assuming your column to insert the value in is "H"



Sub yes()

Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row

Range("H1 :H" & lr).Value = "Yes"
End Sub

dhivya.enjoy
10-23-2013, 12:59 PM
Hi,

Thanks for the code,

I tried the below piece of code since mine is the modification in the new csv file being genarated in the same csv



wbkNew.Sheets(1).Range("L3").Activate 'DOMAIN_NAME
For i = 1 To wbkNew.Sheets(1).Range("A1").End(xlDown).Row - 2
ActiveCell.Value = "GRK"
ActiveCell.Offset(1).Activate
Next i
wbkNew.Sheets(1).Range("A1").Activate

This works fine