logo
down
shadow

Insert Missing Years between 2 years


Insert Missing Years between 2 years

By : M Hall
Date : November 21 2020, 07:31 AM
Does that help TESTED
First off, you should always avoid using Select and ActiveCell as described here.
code :
With Worksheets("Sheet1")
    newYear = .Cells(n, 2).Value
    YearDifference = .Cells(n, 3).Value - newYear
    For j = 0 To YearDifference - 1
        .Cells(n + j, 1).Value = .Cells(n, 1).Value
        .Cells(n + j, 2).Value = newYear
        newYear = newYear + 1
        .Cells(n + j, 3).Value = newYear
    Next j
End With
Sub InsertTest()

Dim LastRow         As Long
Dim newYear         As Long
Dim YearDifference  As Long
Dim n As Long, j As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

With Worksheets("Sheet1")
    LastRow = .Cells(Rows.Count, 2).End(xlUp).Row
    For n = LastRow To 1 Step -1
        If n Mod 10 = 0 Then DoEvents
        If .Cells(n, 1).Value <> "" Then
            newYear = .Cells(n, 2).Value
            YearDifference = .Cells(n, 3).Value - newYear
            If YearDifference > 1 Then
                Application.StatusBar = "Updating Row #" & n
                .Range(.Cells(n + 1, 1), .Cells(n + YearDifference - 1, 15)).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
                For j = 0 To YearDifference - 1
                    .Rows(n + j).Value = .Rows(n).Value
                    .Cells(n + j, 2).Value = newYear
                    newYear = newYear + 1
                    .Cells(n + j, 3).Value = newYear
                Next j
            End If
        End If
    Next n
End With

Application.StatusBar = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub


Share : facebook icon twitter icon
I want fill five years in a drop-down using javascript and the years will be after the current years

I want fill five years in a drop-down using javascript and the years will be after the current years


By : user3161236
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I want fill five years in a drop-down using javascript and the years will be after the current year. , HTML
code :
<form id="someform">
<select id="year"></select>
</form>
var myselect = document.getElementById("year"), year = new Date().getFullYear();
var gen = function(max){do{myselect.add(new Option(year++,max--),null);}while(max>0);}(5);
var myselect = document.getElementById("year"),
    startYear = new Date().getFullYear()
    count = 5;

(function(select, val, count) {
  do {
    select.add(new Option(val++, count--), null);
  } while (count);
})(myselect, startYear, count);
R - How to make stacked bargraph for data over years with missing years

R - How to make stacked bargraph for data over years with missing years


By : Jim Jennings
Date : March 29 2020, 07:55 AM
should help you out Here is my plot in R: , Extending Greg's answer from above, try this:
code :
years <- c(1980, 1984, 1984, 1986, 1988)
pubs  <- c("book","book","poem","poem","book")
mypubs <- data.frame(years,pubs)

mypubs$years<-factor(mypubs$years, levels = as.character(1980:1990))

counts <- table(mypubs$pubs,mypubs$years)
barplot(counts,main="pubs per year",xlab="year",col=c("darkblue","red"),legend=rownames(counts))
php code to insert all Years between two selected years

php code to insert all Years between two selected years


By : Mitchell Green
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further i am using cakephp..
code :
public function addVin(){
    $this->layout = "backend";
    if($this->request->is('post')){      
        $this->loadModel('VinStore');       
            $from = $this->request->data['VinStore']['MDL_YR'];
            $to = $this->request->data['VinStore']['MDL_YR_To'];
            $count = $to - $from; 
            for ($i=0; $i<=$count; $i++) {  
                $year = $from++;
                $this->request->data['VinStore']['MDL_YR'] = $year;
                $this->VinStore->create();                
                $this->VinStore->save($this->request->data);
                $to--;
            }
            $this->Session->setFlash("Vin Data has been added");
            $this->redirect('/admins/addVin'); 



    }
Pandas-Add missing years in time series data with duplicate years

Pandas-Add missing years in time series data with duplicate years


By : Santosh Acharya
Date : March 29 2020, 07:55 AM
wish of those help I have a dataset like this where data for some years are missing . , Make a MultiIndex so you don't have duplicates:
code :
df.set_index(['County', 'Year'], inplace=True)
index = pd.MultiIndex.from_product(df.index.levels)
df.reindex(index)
Python Pandas : Make a Date Range of -2 +5 years e.g: 31 years -> (29-36) years

Python Pandas : Make a Date Range of -2 +5 years e.g: 31 years -> (29-36) years


By : lbourg
Date : March 29 2020, 07:55 AM
I hope this helps . First extract numeric values and then join together with add 2 and subtract 5:
code :
s = df['age'].str.extract('(\d+)', expand=False).astype(int)
df['age_range'] = s.sub(2).astype(str) + '-' + s.add(5).astype(str) + ' years'
#python 3.6+
df['age_range'] = [f'{x-2}-{x + 5} years' for x in s]
#python bellow
#df['age_range'] = ['{}-{} years'.format(x-2, x+5) for x in s]

print (df)
        age    age_range
0  31 years  29-36 years
1  25 years  23-30 years
Related Posts Related Posts :
  • Excel - VB - Re-ordering /Renaming columns
  • "Overload" F9 (or shift+F9) in Excel spreadsheet with VBA function?
  • ShowAllData method of Worksheet class failed
  • VBA If cell is under a certain length, highlight and display message
  • VBA: Unable to get the Match property of the WorkSheet function class
  • Highlighting the second and more duplicate rows in excel but not first occurrence?
  • Excel add- in focus not returned to the active sheet
  • How to restrict VBA code to a specific worksheet?
  • How to insert column name in the destination table in ssis?
  • Insert text into the background of a cell
  • how do I generate random timestamps in Excel
  • VBScript Opening folder to convert csv to xls
  • Creating a VBA Refresh Macro in Smart View for Oracle
  • Excel Performance issues with countif on multiple rows
  • excel vba http request download data from yahoo finance
  • Excel Vba Loop , not running properly
  • Efficiently hiding / unhiding many (+500) rows in Excel VBA
  • Excel's Find function; Exceptions over values
  • reading data from an excel sheet in perl
  • Using Webservice function in Excel to pull "Next Earnings Date" from Yahoo Finance using Yahoo API
  • Three And (&)'s into an if statement VBA for Excel
  • Certain fractions being calculated in excel 2013
  • Excel formula to find sum of difference
  • countfis or sum if array to work out if given time is between the value of two columns
  • Error in Date Cell in CSV
  • Syntax while trying to include The multi-part identifier [°C] in command text
  • How to find day of the week from known date and month but variable year
  • Modify Marker Transparency with Excel VBA
  • Excel tricky formula
  • Loop Though All UDF Names in Project
  • Searching for function usage in Excel VBA
  • Convert from list to flat CSV with modified data
  • Count how many words from a list appear in a cell
  • Creating hierarchical sequence in Excel using several functions in formula
  • On Error GoTo statement is still executing although there is no error generated
  • Find last digits with IF
  • Use Excel VBA to find column matches & merge based on the values of two other column
  • PowerPivot not sending Authorization header in Basic Authentication to OData Svc
  • Vlookup not working with text search
  • Paste value from a Userform to a Excel Sheet
  • Excel 2010 Macro to compare two columns for finding the matched value
  • #VALUE error when dealing with long string in UDF in VBA(excel)
  • Refer to a cell in another worksheet by referencing the current sheet's name
  • VBA Excel 2007 : Need to loop copy and loop count number except zero every row above
  • Excel: Conditional probabilities of winning a tiebreaker game
  • How to find groups of individuals who attended multiple events together?
  • Using DateTime when referencing a cell with SUMIFS()
  • VBA Copy & Transpose Data Range
  • Huge excel file... any advice?
  • Looped macro to create a new sheet, rename it, add data from the web, then loop back through until complete
  • copy paste of tab delimited text results in strange formatting in Excel?
  • Excel user defined function: Nth_Occurence
  • Excel ActiveX Button is clickable, but does not work
  • Array Formula Conditional Count
  • YEAR() fitting to WEEKNUM(...,21) in Excel
  • Macro that follows a link and downloads the table into a new sheet
  • How to Concatenate multiple columns if not empty
  • Excel - List all the combinations of two words from one list, in two other columns
  • How do I do my Pentaho Report take the Excel datasource file along to BA/BI Server?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org