Going from one set of looped commands to another

and this is the coding for the sonar sensor:

int trigPin1=4;
int echoPin1=2;

int trigPin2=6;
int echoPin2=7;



void setup() {
  Serial.begin (9600);
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);

}

void loop() {
  long duration1, distance1;
  digitalWrite(trigPin1, LOW);  // 
  delayMicroseconds(2); // 
  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10); // 
  digitalWrite(trigPin1, LOW);
  duration1 = pulseIn(echoPin1, HIGH);
  distance1 = (duration1) / 29.1/2; //converts value from sensor to cm (divided by two to compensate for relay time)

   if (distance1 >= 1000 || distance1 <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print ( "Sensor1  ");
    Serial.print ( distance1);
    Serial.println("cm");
  }
  delay(1000);
 
}