can I use #ifdef, #elif #endif here?

not sure if it actually will make a difference in terms of how much memory this code would used up but was wondering if it is possible to use #ifdef in place of "if" in the code. any ideas?

void setTimer1(unsigned long microseconds){
  //oldSREG = SREG;				
  
  TIMSK1 &= ~(1<<TOIE1);                                   // clears the timer overflow interrupt enable bit
  TCCR1B &= ~((1<<CS10) | (1<<CS11) | (1<<CS12));          // clears all clock selects bits (Timer/Counter stopped)
  TIFR1 &= ~(1<<TOV1);       //Clear Timer overflow flag
  
  cycles=(microseconds*(F_CPU/1000000));
  
  if(cycles < RESOLUTION){
    clockSelectBits = 0x01; 
	tcnt1_HL = cycles;	// no prescale
	tcnt1_HL=(RESOLUTION-1)-tcnt1_HL;
	TCNT1 = tcnt1_HL;						   //initialise TCNT1
  }
  else if(cycles < (RESOLUTION*8)){
	clockSelectBits = 0x02;              // prescale by /8
	tcnt1_HL = cycles/8;
	tcnt1_HL=(RESOLUTION-1)-tcnt1_HL;
	TCNT1 = tcnt1_HL;						   //initialise TCNT1
  }
  else if(cycles < (RESOLUTION*64)){
    clockSelectBits = 0x03;  // prescale by /64;
	tcnt1_HL = cycles/64;
	tcnt1_HL=(RESOLUTION-1)-tcnt1_HL;
	TCNT1 = tcnt1_HL;						   //initialise TCNT1
  }
  else if(cycles < (RESOLUTION*256)){
    clockSelectBits = 0x04;  // prescale by /256
	tcnt1_HL = cycles/256;
	tcnt1_HL=(RESOLUTION-1)-tcnt1_HL;
	TCNT1 = tcnt1_HL;						   //initialise TCNT1
  }
  else if(cycles < (RESOLUTION*1024)){
    clockSelectBits = 0x05;  // prescale by /1024
	tcnt1_HL = cycles/1024;
	tcnt1_HL=(RESOLUTION-1)-tcnt1_HL;
	TCNT1 = tcnt1_HL;						   //initialise TCNT1
  }
  else{
	cycles = RESOLUTION - 1;
	clockSelectBits = 0x05;  // request was out of bounds, set as maximum
	tcnt1_HL = 0;
	TCNT1 = 0;						   //initialise TCNT1
  }
  
  TCCR1B |= clockSelectBits;       //set prescale bits
  TIMSK1 |= (1<<TOIE1);           // sets the timer overflow interrupt enable bit
  
}

#ifdef is a preprocessor directive, meaning that is reduced/optimized at compile time, therefore the values must be know at compile time.

You cannot because cycles is a runtime variable and the value of cycles is not know during compilation.

There does appear to be some possible ways to reduce the code. You'll have to change your thinking a bit. The premise is based on the fact that two lines appear in 5 of the 6 cases (ie., you have replicated code), furthermore the if criteria (*1, *8, *64) is also used in the formula of the if statement.

As adwsystems points out, there are no calculations mad during pre-processing so the use of variables is a non-starter. There are ways to cheat though if you can define all these variables in advance. For example, you want to choose one of your ifs based on cycles which in turn is based on microseconds and F_CPU. F_CPU is known at compile time. If microseconds can also be defined at compile time then the operation is simple. If, however, you plan to continually change the timer base in your code, you're stuck. However, the only thing changing is the prescaler which varies according to 8^(clockSelectBits - 1), so all your if/else if statements (or most of them) can be replaced with

if(cycles < RESOLUTION) clockSelectBits = 0x01;
else if(cycles < (RESOLUTION*8)) clockSelectBits = 0x02;
else if(cycles < (RESOLUTION*64)) clockSelectBits = 0x03;
else if(cycles < (RESOLUTION*256)) clockSelectBits = 0x04;
else if(cycles < (RESOLUTION*1024)) clockSelectBits = 0x05;
else (figure this on your own)
int prescaler = pow(8,(clockSelectBits - 1));
tcnt1_HL = cycles/prescaler;
tcnt1_HL=(RESOLUTION-1)-tcnt1_HL;
TCNT1 = tcnt1_HL;						   //initialise TCNT1

And there's probably a more elegant way of doing it, but that's the gist.

DKWatson:
As adwsystems points out, there are no calculations mad during pre-processing so the use of variables is a non-starter. There are ways to cheat though if you can define all these variables in advance. For example, you want to choose one of your ifs based on cycles which in turn is based on microseconds and F_CPU. F_CPU is known at compile time. If microseconds can also be defined at compile time then the operation is simple. If, however, you plan to continually change the timer base in your code, you're stuck. However, the only thing changing is the prescaler which varies according to 8^(clockSelectBits - 1), so all your if/else if statements (or most of them) can be replaced with

if(cycles < RESOLUTION) clockSelectBits = 0x01;

else if(cycles < (RESOLUTION8)) clockSelectBits = 0x02;
else if(cycles < (RESOLUTION
64)) clockSelectBits = 0x03;
else if(cycles < (RESOLUTION256)) clockSelectBits = 0x04;
else if(cycles < (RESOLUTION
1024)) clockSelectBits = 0x05;
else (figure this on your own)
int prescaler = pow(8,(clockSelectBits - 1));
tcnt1_HL = cycles/prescaler;
tcnt1_HL=(RESOLUTION-1)-tcnt1_HL;
TCNT1 = tcnt1_HL;   //initialise TCNT1


And there's probably a more elegant way of doing it, but that's the gist.

I don't know if there is a more elegant way nor a more compact way. This is exactly what I was trying to do. I ran out of time to figure out the relationship between clockSelectBits and prescaler (I see you found it, nice job).