Is there an easier way ?

So i made an 3x3 led matrix (this is the first time i am using arduino and this language btw), and i made this code taken from various sources (the multiplexing thing got me mad), but it seams kinda repetitive is there another way to do it ?
2,3,4, are anodes and 567 are catodes, and here is the code:

void setup() {
  pinMode (2, OUTPUT);
  pinMode (3, OUTPUT);
  pinMode (4, OUTPUT);
  pinMode (5, OUTPUT);
  pinMode (6, OUTPUT);
  pinMode (7, OUTPUT);

}
void loop() {
  for(int a= 0; a <70; a++){
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
    digitalWrite(2, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(2, LOW);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
  }
  for(int b= 0; b <70; b++){
    digitalWrite(2, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(2, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    delay(1);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
  }

  for(int c= 0; c <70; c++){
    digitalWrite(3, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(3, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    delay(1);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
  }
  for(int d= 0; d <70; d++){
    digitalWrite(4, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(4, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(7, HIGH);
    delay(1);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
    digitalWrite(7, LOW);
    digitalWrite(2, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    delay(1);
    digitalWrite(2, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
  }    
}

You could simplify it a bit with:

void toggleLeds(int led1, int led2, int led3, bool state)
{
    digitalWrite(led1, state);
    digitalWrite(led2, state);
    digitalWrite(led3, state);
    delay(1);
    digitalWrite(led1, !state);
    digitalWrite(led2, !state);
    digitalWrite(led3, !state);
}

and change your code to something like:

  for(int a= 0; a <70; a++){
    toggleLed(4, 5, 7, HIGH);
    toggleLed(3, 5, 7, HIGH);
    // and so on...

This change doesn’t do much, but makes it a little easier to read.

thanks. Anything is welcomed, because i am trying to learn a bit how this works and make it more easier. After i get a grip on this i am planing to make a 10x16 led matrix with 74hc595, so any improvements on the code is more than welcomed.

well here is the result:

void setup() {
  pinMode (2, OUTPUT);
  pinMode (3, OUTPUT);
  pinMode (4, OUTPUT);
  pinMode (8, OUTPUT);
  pinMode (9, OUTPUT);
  pinMode (10, OUTPUT);

}
void toggleLed(int led1, int led2, int led3, bool state)
{
  digitalWrite(led1, state);
  digitalWrite(led2, state);
  digitalWrite(led3, state);
}
void loop() {
  for (int a = 0; a < 100; a++) {
    toggleLed(4, 8, 10, HIGH);
    delay(1);
    toggleLed(4, 8, 10, LOW);
    toggleLed(3, 8, 10, HIGH);
    delay(1);
    toggleLed(3, 8, 10, LOW);
    toggleLed(2, 8, 10, HIGH);
    delay(1);
    toggleLed(2, 8, 10, LOW);
  }
  for (int b = 0; b < 100; b++) {
    toggleLed(2, 9, 10, HIGH);
    delay(1);
    toggleLed(2, 9, 10, LOW);
    toggleLed(3, 8, 10, HIGH);
    delay(1);
    toggleLed(3, 8, 10, LOW);
    toggleLed(4, 8, 9, HIGH);
    delay(1);
    toggleLed(4, 8, 9, LOW);
  }
  for (int c = 0; c < 100; c++) {
    toggleLed(3, 9, 10, HIGH);
    delay(1);
    toggleLed(3, 9, 10, LOW);
    toggleLed(3, 8, 10, HIGH);
    delay(1);
    toggleLed(3, 8, 10, LOW);
    toggleLed(3, 8, 9, HIGH);
    delay(1);
    toggleLed(3, 8, 9, LOW);
  }
  for (int d = 0; d < 100; d++) {
    toggleLed(4, 9, 10, HIGH);
    delay(1);
    toggleLed(4, 9, 10, LOW);
    toggleLed(3, 8, 10, HIGH);
    delay(1);
    toggleLed(3, 8, 10, LOW);
    toggleLed(2, 8, 9, HIGH);
    delay(1);
    toggleLed(2, 8, 9, LOW);
  }
}

I have modified some pins but it is much better than before so thaks a lot.